@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
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{k as $,l as I}from"./chunk-4I7YN6YY.js";import{randomUUID as q}from"crypto";var f=class extends Error{constructor(i,a,t,r=null,n=null,c={},u=null){super(t);this.status=i;this.code=a;this.failed=r;this.seq=n;this.extra=c;this.requestId=u;this.name="LatticeError"}get retryable(){return this.status===0||this.status===502||this.status===503||this.status===504}get forPerson(){return this.code==="UNREACHABLE"?"Lattice did not answer":this.code==="UNEXPECTED_ANSWER"?"Lattice gave an answer the session host could not read":this.message}};function Y(e,l){let i=Number(e.headers.get(l));return Number.isInteger(i)&&i>0?i:null}function B(e,l,i,a){let t=null;try{t=JSON.parse(l.toString("utf8"))}catch{}let r=t?.error;if(typeof r?.code=="string"&&typeof r.message=="string"){let{code:n,message:c,failed:u,seq:d,...R}=r;return new f(e.status,n,c,typeof u=="string"?u:null,typeof d=="number"?d:null,R,a)}return new f(e.status,"UNEXPECTED_ANSWER",`${i} answered ${e.status} without the contract's error body; check Lattice's log`,null,null,{},a)}function D(e){let l=$(),i=I();return{"x-request-id":e,...l!==null?{"x-user-session-id":l}:{},...i!==null?{"user-agent":`kane-cli/${i}`}:{}}}var P=6e4,U=64*1024;function C(e){let l=e.fetch??((t,r)=>fetch(t,r));async function i(t,r,n,{headers:c={},bulk:u=!1,route:d,onSend:R}={}){let g=/^https?:\/\//i.test(r),m=d??(g?`${t} upload`:`${t} ${r}`),w=g?null:q(),b={...g?{}:{authorization:e.basicAuth,...D(w)},...Object.fromEntries(Object.entries(c).map(([s,o])=>[s.toLowerCase(),o]))},h,S=n instanceof Buffer&&n.length>U;if(n instanceof Buffer)if(b["content-type"]??="application/octet-stream",S){b["content-length"]=String(n.length);let s=0;h=new ReadableStream({pull(o){if(s>=n.length)return o.close();let p=n.subarray(s,s+U);s+=p.length,y(),e.onSend?.(m,s,n.length),R?.(s,n.length),o.enqueue(new Uint8Array(p))}})}else h=new Uint8Array(n);else n!==void 0&&(b["content-type"]="application/json",h=JSON.stringify(n));let N=e.requestDeadlineMs??P,_=new AbortController,E=!1,T,y=()=>{clearTimeout(T),T=setTimeout(()=>{E=!0,_.abort()},N)};y();try{let s={method:t,headers:b,signal:_.signal,...h!==void 0?{body:h}:{},...S?{duplex:"half"}:{}},o=await l(g?r:`${e.url}${r}`,s);(u||S)&&y();let p=[],x=o.headers.get("content-encoding")?Number(o.headers.get("lattice-history-bytes")??NaN):Number(o.headers.get("content-length")??NaN),M=Number.isFinite(x)?x:null,A=0;if(o.body){let v=o.body.getReader();for(;;){let{done:k,value:L}=await v.read();if(k)break;p.push(L),u&&(y(),A+=L.byteLength,e.onBody?.(m,A,M))}}let O=Buffer.concat(p);if(!o.ok)throw B(o,O,m,w);return{response:o,bytes:O}}catch(s){if(s instanceof f)throw s;let o=E?`no answer within ${N/1e3} s${u?" of its last part":""}`:s instanceof Error?s.message:String(s);throw new f(0,"UNREACHABLE",g?`${m} did not reach the upload's address: ${E?o:"the connection failed"}`:`${m} did not reach Lattice at ${e.url}: ${o}`,null,null,{},w)}finally{clearTimeout(T)}}async function a(t,r,n,c=!1){let{response:u,bytes:d}=await i(t,r,n,{bulk:c});if(u.status!==204)return JSON.parse(d.toString("utf8"))}return{exchange:i,request:a}}function H(e=12e4,l=a=>new Promise(t=>setTimeout(t,a)),i=Date.now){let a=null,t=500,r=0;return{async again(n){a??=i();let c=a+e-i();if(c<=0)return!1;r+=1;let u=Math.min(t,c);return n?.(u),await l(u),t=Math.min(t*2,1e4),!0},get attempt(){return r},endsAt(){return a===null?null:a+e},reset(){a=null,t=500,r=0}}}export{f as a,Y as b,P as c,C as d,H as e};
2
+ import{k as $,n as I}from"./chunk-HYJVYYAZ.js";import{randomUUID as q}from"crypto";var f=class extends Error{constructor(i,a,t,r=null,n=null,c={},u=null){super(t);this.status=i;this.code=a;this.failed=r;this.seq=n;this.extra=c;this.requestId=u;this.name="LatticeError"}get retryable(){return this.status===0||this.status===502||this.status===503||this.status===504}get forPerson(){return this.code==="UNREACHABLE"?"Lattice did not answer":this.code==="UNEXPECTED_ANSWER"?"Lattice gave an answer the session host could not read":this.message}};function Y(e,l){let i=Number(e.headers.get(l));return Number.isInteger(i)&&i>0?i:null}function B(e,l,i,a){let t=null;try{t=JSON.parse(l.toString("utf8"))}catch{}let r=t?.error;if(typeof r?.code=="string"&&typeof r.message=="string"){let{code:n,message:c,failed:u,seq:d,...R}=r;return new f(e.status,n,c,typeof u=="string"?u:null,typeof d=="number"?d:null,R,a)}return new f(e.status,"UNEXPECTED_ANSWER",`${i} answered ${e.status} without the contract's error body; check Lattice's log`,null,null,{},a)}function D(e){let l=$(),i=I();return{"x-request-id":e,...l!==null?{"x-user-session-id":l}:{},...i!==null?{"user-agent":`kane-cli/${i}`}:{}}}var P=6e4,U=64*1024;function C(e){let l=e.fetch??((t,r)=>fetch(t,r));async function i(t,r,n,{headers:c={},bulk:u=!1,route:d,onSend:R}={}){let g=/^https?:\/\//i.test(r),m=d??(g?`${t} upload`:`${t} ${r}`),w=g?null:q(),b={...g?{}:{authorization:e.basicAuth,...D(w)},...Object.fromEntries(Object.entries(c).map(([s,o])=>[s.toLowerCase(),o]))},h,S=n instanceof Buffer&&n.length>U;if(n instanceof Buffer)if(b["content-type"]??="application/octet-stream",S){b["content-length"]=String(n.length);let s=0;h=new ReadableStream({pull(o){if(s>=n.length)return o.close();let p=n.subarray(s,s+U);s+=p.length,y(),e.onSend?.(m,s,n.length),R?.(s,n.length),o.enqueue(new Uint8Array(p))}})}else h=new Uint8Array(n);else n!==void 0&&(b["content-type"]="application/json",h=JSON.stringify(n));let N=e.requestDeadlineMs??P,_=new AbortController,E=!1,T,y=()=>{clearTimeout(T),T=setTimeout(()=>{E=!0,_.abort()},N)};y();try{let s={method:t,headers:b,signal:_.signal,...h!==void 0?{body:h}:{},...S?{duplex:"half"}:{}},o=await l(g?r:`${e.url}${r}`,s);(u||S)&&y();let p=[],x=o.headers.get("content-encoding")?Number(o.headers.get("lattice-history-bytes")??NaN):Number(o.headers.get("content-length")??NaN),M=Number.isFinite(x)?x:null,A=0;if(o.body){let v=o.body.getReader();for(;;){let{done:k,value:L}=await v.read();if(k)break;p.push(L),u&&(y(),A+=L.byteLength,e.onBody?.(m,A,M))}}let O=Buffer.concat(p);if(!o.ok)throw B(o,O,m,w);return{response:o,bytes:O}}catch(s){if(s instanceof f)throw s;let o=E?`no answer within ${N/1e3} s${u?" of its last part":""}`:s instanceof Error?s.message:String(s);throw new f(0,"UNREACHABLE",g?`${m} did not reach the upload's address: ${E?o:"the connection failed"}`:`${m} did not reach Lattice at ${e.url}: ${o}`,null,null,{},w)}finally{clearTimeout(T)}}async function a(t,r,n,c=!1){let{response:u,bytes:d}=await i(t,r,n,{bulk:c});if(u.status!==204)return JSON.parse(d.toString("utf8"))}return{exchange:i,request:a}}function H(e=12e4,l=a=>new Promise(t=>setTimeout(t,a)),i=Date.now){let a=null,t=500,r=0;return{async again(n){a??=i();let c=a+e-i();if(c<=0)return!1;r+=1;let u=Math.min(t,c);return n?.(u),await l(u),t=Math.min(t*2,1e4),!0},get attempt(){return r},endsAt(){return a===null?null:a+e},reset(){a=null,t=500,r=0}}}export{f as a,Y as b,P as c,C as d,H as e};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as l}from"./chunk-QQI6N3FO.js";import{e as d,h as p}from"./chunk-XMPTFXPW.js";import{b as f}from"./chunk-REKHAN53.js";import{Ha as i,s as g}from"./chunk-TLOYTGVT.js";import{a as c}from"./chunk-FOJHSG5M.js";var h=new Set(["context extract","design tests","context sessions","context ingest","context list","maintain reconcile","maintain evolve","cover","context pull","context impact"]),I=new Set(["context ingest","context extract"]),y=new Set(["testmd run","testrun run"]),w=new Set(["context","design","maintain","cover"]);function $(e,n){return n.kind==="local"||n.kind==="pick"||!w.has(e.split(" ")[0])?null:n.kind==="refuse"?n.refusal:w.has(e)||h.has(e)||y.has(e)?null:i.notYet(e)}var R={tests:"design",sessions:"save","sessions discard":"discard",ingest:"extract",list:"list",reconcile:"reconcile"};function a(e,n,t){return t?p(d("ndjson",R[n]??n),e.message,e.code,e.remedy):(k(e),2)}function G(e,n,t){if(e.code!=="LIST_FAILED"&&e.code!=="COVERAGE_FAILED")return a(e,n,t);if(t){let r=d("ndjson",R[n]??n);return r.event({type:"error",code:e.code,message:e.message,...e.remedy?{remedy:e.remedy}:{}}),r.done(1)}return k(e),1}function E(e,n){if(!e.answer?.length)return null;let t=f({answer:e.answer});return t.ok?e.resume?e.mode!=="agent"?i.answerAgentOnly(n,e.resume):null:i.answerNeedsResume():i.answerParse(t.error)}function v(e,n){if(!e.answer?.length||l(process.cwd()).kind!=="remote")return null;let t=E(e,n);return t===null?null:a(t,n.split(" ")[1],e.mode==="agent")}var B=e=>`${c.green(`\u2713 Project: "${e}"`)}
2
+ import{b as l}from"./chunk-3RO2YGKH.js";import{e as d,h as p}from"./chunk-XMPTFXPW.js";import{b as f}from"./chunk-REKHAN53.js";import{Ha as i,s as g}from"./chunk-WE7HRAGO.js";import{a as c}from"./chunk-FOJHSG5M.js";var h=new Set(["context extract","design tests","context sessions","context ingest","context list","maintain reconcile","maintain evolve","cover","context pull","context impact"]),I=new Set(["context ingest","context extract"]),y=new Set(["testmd run","testrun run"]),w=new Set(["context","design","maintain","cover"]);function $(e,n){return n.kind==="local"||n.kind==="pick"||!w.has(e.split(" ")[0])?null:n.kind==="refuse"?n.refusal:w.has(e)||h.has(e)||y.has(e)?null:i.notYet(e)}var R={tests:"design",sessions:"save","sessions discard":"discard",ingest:"extract",list:"list",reconcile:"reconcile"};function a(e,n,t){return t?p(d("ndjson",R[n]??n),e.message,e.code,e.remedy):(k(e),2)}function G(e,n,t){if(e.code!=="LIST_FAILED"&&e.code!=="COVERAGE_FAILED")return a(e,n,t);if(t){let r=d("ndjson",R[n]??n);return r.event({type:"error",code:e.code,message:e.message,...e.remedy?{remedy:e.remedy}:{}}),r.done(1)}return k(e),1}function E(e,n){if(!e.answer?.length)return null;let t=f({answer:e.answer});return t.ok?e.resume?e.mode!=="agent"?i.answerAgentOnly(n,e.resume):null:i.answerNeedsResume():i.answerParse(t.error)}function v(e,n){if(!e.answer?.length||l(process.cwd()).kind!=="remote")return null;let t=E(e,n);return t===null?null:a(t,n.split(" ")[1],e.mode==="agent")}var B=e=>`${c.green(`\u2713 Project: "${e}"`)}
3
3
  ${c.dim(" this folder is now linked to it; what you save goes to the project")}
4
4
  `;function k(e){if(process.stderr.write(`${u(`error: ${e.message}`)}
5
5
  `),e.detail&&process.stderr.write(`${c.dim(` ${e.detail}`)}
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{m as d}from"./chunk-4I7YN6YY.js";function a(n,e){return n.trust.get(e)}function c(n,e){return a(n,e)==="derived"?"unreviewed":void 0}function u(n,e){let t=n.resolve(e);if(!t)return{ok:!1,code:"UNKNOWN_REF",detail:`${e} names nothing in the graph`};let r=t.tip,i=a(n,r),o=d(),s=o.command("next.review_use_case",{use_case:e});return i==="archived"?{ok:!1,code:"UC_ARCHIVED",detail:`${e} is archived (previously rejected by the owner) \u2014 re-approve it before designing`,ref:e,...s!==null?{reviewCmd:s}:{}}:i==="derived"?{ok:!1,code:"UC_UNREVIEWED",detail:o.text("UC_UNREVIEWED",{use_case:e}),ref:e,...s!==null?{reviewCmd:s}:{}}:{ok:!0}}function g(n,e){if(!e.useCase||e.allowUnreviewed||e.resuming&&e.sessionUseCase===e.useCase)return null;let t=u(n,e.useCase);return!t.ok&&(t.code==="UC_UNREVIEWED"||t.code==="UC_ARCHIVED")?t:null}function p(n){return n.code==="UC_UNREVIEWED"}function v(n,e){return a(n,e)==="derived"?"quarantine":"evidence-attach"}async function f(n,e){let t={id:"trust-gate",header:"unreviewed use-case",text:`design: ${e.detail??"this use-case is unreviewed"} \u2014 design against it anyway?`,risk:"high",rationale:e.reviewCmd?`approve it first: ${e.reviewCmd}`:"",options:[{label:"no \u2014 approve it first",detail:e.reviewCmd??"review it before designing"},{label:"design against it anyway",detail:"the design will build on an unreviewed use-case"}],recommended_index:0,allow_free_text:!1},r=await n([t]);return Array.isArray(r)?r.find(i=>i.id==="trust-gate")?.selected_index===1:!1}export{a,c as b,u as c,g as d,p as e,v as f,f as g};
2
+ import{o as d}from"./chunk-HYJVYYAZ.js";function a(n,e){return n.trust.get(e)}function c(n,e){return a(n,e)==="derived"?"unreviewed":void 0}function u(n,e){let t=n.resolve(e);if(!t)return{ok:!1,code:"UNKNOWN_REF",detail:`${e} names nothing in the graph`};let r=t.tip,i=a(n,r),o=d(),s=o.command("next.review_use_case",{use_case:e});return i==="archived"?{ok:!1,code:"UC_ARCHIVED",detail:`${e} is archived (previously rejected by the owner) \u2014 re-approve it before designing`,ref:e,...s!==null?{reviewCmd:s}:{}}:i==="derived"?{ok:!1,code:"UC_UNREVIEWED",detail:o.text("UC_UNREVIEWED",{use_case:e}),ref:e,...s!==null?{reviewCmd:s}:{}}:{ok:!0}}function g(n,e){if(!e.useCase||e.allowUnreviewed||e.resuming&&e.sessionUseCase===e.useCase)return null;let t=u(n,e.useCase);return!t.ok&&(t.code==="UC_UNREVIEWED"||t.code==="UC_ARCHIVED")?t:null}function p(n){return n.code==="UC_UNREVIEWED"}function v(n,e){return a(n,e)==="derived"?"quarantine":"evidence-attach"}async function f(n,e){let t={id:"trust-gate",header:"unreviewed use-case",text:`design: ${e.detail??"this use-case is unreviewed"} \u2014 design against it anyway?`,risk:"high",rationale:e.reviewCmd?`approve it first: ${e.reviewCmd}`:"",options:[{label:"no \u2014 approve it first",detail:e.reviewCmd??"review it before designing"},{label:"design against it anyway",detail:"the design will build on an unreviewed use-case"}],recommended_index:0,allow_free_text:!1},r=await n([t]);return Array.isArray(r)?r.find(i=>i.id==="trust-gate")?.selected_index===1:!1}export{a,c as b,u as c,g as d,p as e,v as f,f as g};
@@ -1,7 +1,7 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as ne,b as te,c as re,d as ie,e as z}from"./chunk-5T6II7VN.js";import{b as se,c as oe}from"./chunk-IINZZ4BZ.js";import{n as ee,p as j}from"./chunk-UJLULWSR.js";import{a as $e}from"./chunk-6YGTRKDT.js";import{e as Te}from"./chunk-UR6MHSHU.js";function Oe(r){let e=r==="passed"?"passed":"failed";return{testStatus:e,remark:`kane-cli: ${e}`}}var Le={testStatus:"failed",remark:"cancelled"};var Ae="https://www.testmuai.com/pricing/",De=/Real Mobile App Automation not allowed on your current plan/i,L=class extends Error{code="plan_required";constructor(e){super(e),this.name="RealDevicePlanError"}};function ae(r){return!r||!De.test(r)?null:["Real devices aren't included in your TestMu AI plan.","Running on a real device needs the KaneAI Max or Real Device Plus Automation Cloud plan.",`See plans: ${Ae}`].join(`
3
- `)}function ue(r){return{command:"start",...r}}function de(r,e,s){return{command:"run",run_id:r,kind:e,...s}}function le(r){return{command:"cancel",...r?{run_id:r}:{}}}function ce(r){return{command:"ask_user_response",answer:r}}function pe(r={}){return{command:"shutdown",...r.testStatus?{test_status:r.testStatus,remark:r.remark??""}:{}}}var W=Symbol("run-queue-end"),J=class{items=[];waiting=null;ended=!1;error=null;push(e){if(this.waiting){let{resolve:s}=this.waiting;this.waiting=null,s(e)}else this.items.push(e)}end(){if(this.ended=!0,this.waiting){let{resolve:e}=this.waiting;this.waiting=null,e(W)}}fail(e){if(this.error=e,this.waiting){let{reject:s}=this.waiting;this.waiting=null,s(e)}}next(){return this.items.length>0?Promise.resolve(this.items.shift()):this.error?Promise.reject(this.error):this.ended?Promise.resolve(W):new Promise((e,s)=>{this.waiting={resolve:e,reject:s}})}},F=class{env;runner;log;sessionId;spawnFn;proc=null;activeRun=null;pendingReady=null;shuttingDown=!1;finalized=!1;exitInfo=null;exitedUnexpectedly=!1;exitResolve;onEvent;exited;constructor(e){this.env=e.env,this.runner=e.runner,this.log=e.log,this.sessionId=e.sessionId,this.spawnFn=e.spawn??te,this.onEvent=e.onEvent;let s;this.exited=new Promise(d=>{s=d}),this.exitResolve=s}async start(e){if(this.proc)throw new Error("PersistentRunner.start called twice");this.proc=this.spawnFn({env:this.env,runner:this.runner,log:this.log,sessionId:this.sessionId}),this.consume();let s=new Promise((d,g)=>{this.pendingReady={resolve:d,reject:g}});this.writeCommand(ue(e)),await s}async*run(e,s,d){if(!this.proc)throw new Error("PersistentRunner.run called before start");if(this.finalized)throw new Error(`v16-runner is not running (exited code=${this.exitInfo?.code??"null"}, signal=${this.exitInfo?.signal??"none"}) \u2014 cannot start run '${e}'`);if(this.activeRun)throw new Error(`PersistentRunner.run overlap: '${this.activeRun.runId}' still in flight`);let g=new J,_={runId:e,queue:g};this.activeRun=_,this.writeCommand(de(e,s,d));try{for(;;){let v=await g.next();if(v===W||(yield v,v.type==="run_end"&&(v.run_id===void 0||v.run_id===e)))break}}finally{this.activeRun===_&&(this.activeRun=null)}}sendUserResponse(e){this.writeCommand(ce(e))}cancel(e){this.writeCommand(le(e))}kill(){this.proc?.child.kill("SIGTERM")}async shutdown(e={}){this.shuttingDown=!0,this.proc&&(this.writeCommand(pe(e)),await this.exited)}get stderr(){return this.proc?.getStderr()??""}get diedUnexpectedly(){return this.exitedUnexpectedly}writeCommand(e){let s=JSON.stringify(e)+`
4
- `;try{this.proc?.child.stdin?.write(s)}catch{}}async consume(){if(!this.proc)return;try{for await(let d of this.proc.events){if(d.type==="ready"){this.onReady();continue}if(d.type==="error"&&this.pendingReady){this.onStartError(d.message);continue}try{this.onEvent?.(d)}catch{}this.routeEvent(d)}}catch(d){this.log?.("error","PERSISTENT_RUNNER_STREAM_ERROR","Runner stdout stream errored",{error:d instanceof Error?d.message:String(d)})}let{code:e,signal:s}=await this.proc.exited;this.onExit(e,s)}onReady(){if(this.pendingReady){let{resolve:e}=this.pendingReady;this.pendingReady=null,e()}}onStartError(e){if(!this.pendingReady)return;let{reject:s}=this.pendingReady;this.pendingReady=null;let d=ae(e);if(d){this.log?.("error","REAL_DEVICE_PLAN_REQUIRED","The mobile hub refused the session over the plan",{reason:e}),s(new L(d));return}s(new Error(`failed to start: ${e??"unknown error"}`))}routeEvent(e){let s=this.activeRun;if(!s){this.log?.("warn","PERSISTENT_RUNNER_ORPHAN_EVENT","Runner event with no active run",{event_type:e.type});return}s.queue.push(e)}onExit(e,s){if(!this.finalized){if(this.finalized=!0,this.exitInfo={code:e,signal:s},this.shuttingDown||(this.exitedUnexpectedly=!0),this.exitResolve({code:e,signal:s}),this.pendingReady){let{reject:d}=this.pendingReady;this.pendingReady=null,d(new Error(`v16-runner exited before ready (code=${e}, signal=${s??"none"})`))}if(this.activeRun){let{queue:d}=this.activeRun;if(this.activeRun=null,this.shuttingDown)d.end();else{let g=this.proc?.getStderr()?.slice(-500)??"";d.fail(new Error(`v16-runner exited unexpectedly mid-run (code=${e}, signal=${s??"none"})${g?`
5
- ${g}`:""}`))}}}}};var p=Te($e(),1);function he(r){let e={cdp_endpoint:r.cdp_endpoint,ws_endpoint:r.ws_endpoint,width:r.width,height:r.height,headless:r.headless,model:r.model,max_steps:r.max_steps,network_ws:r.network_ws,network_sse:r.network_sse,session_id:r.session_id};return r.device&&(e.device=r.device),r.auth&&(e.auth=r.auth),r.project_id&&(e.project_id=r.project_id),r.disable_ask_user&&(e.disable_ask_user=!0),r.media_upload&&(e.media_upload=r.media_upload),r.username&&(e.username=r.username),r.access_key&&(e.access_key=r.access_key),e}function N(r,e){let s=null,d=(g,_)=>{for(let v=0;v<g.length;v++){let E=g[v],h=[..._,v];e(E)&&(s===null||h.length>s.length)&&(s=h),E.children&&E.children.length>0&&d(E.children,h)}};return d(r,[]),s}function T(r,e,s){if(e.length===0)return[...r];let d=e[0],g=[...r],_=g[d];if(e.length===1)g[d]=s(_);else{let v=e.slice(1),E=T(_.children??[],v,s);g[d]={..._,children:E}}return g}var Ue=6e4;function fe(){return{steps:[],maxOrdinal:0}}function Me(r,e){if(e.type==="run_start"&&e.child_id)return e.environment?.resolution?{...r,resolution:e.environment.resolution}:r;if(e.type==="run_start"){let s=oe(r.runnerEnvironment,se(e.environment));if(s)return{...r,runnerEnvironment:s,...s.resolution?{resolution:s.resolution}:{}}}if(e.type==="step_end"&&typeof e.ordinal=="number"&&e.id){let s={id:e.id,ordinal:e.ordinal,status:e.status,...e.kind?{kind:e.kind}:{},...typeof e.duration=="number"?{duration_ms:Math.round(e.duration*1e3)}:{},...typeof e.action_id=="string"&&e.action_id?{action_id:e.action_id}:{}};return{...r,steps:[...r.steps,s],maxOrdinal:Math.max(r.maxOrdinal,e.ordinal)}}return r}function H(r){let e=r.indexOf(": ");return e>0&&e<15?r.slice(e+2):r}function Q(r){return r.map(e=>{let s=e.children?Q(e.children):e.children;return e.status==="running"?{...e,status:"stopped",phase:void 0,children:s}:s!==e.children?{...e,children:s}:e})}function nn(r,e,s,d,g){let[_,v]=(0,p.useState)(!1),[E,h]=(0,p.useState)([]),[me,$]=(0,p.useState)(null),[ve,B]=(0,p.useState)(null),[ge,C]=(0,p.useState)(null),[Re,X]=(0,p.useState)(null),[Se,Y]=(0,p.useState)([]),[ye,Z]=(0,p.useState)(null),[we,xe]=(0,p.useState)(void 0),[_e,A]=(0,p.useState)(0),x=(0,p.useRef)(null),D=(0,p.useRef)(null),k=(0,p.useRef)(null),w=(0,p.useRef)(null),b=(0,p.useRef)(0),V=(0,p.useRef)(!1),U=(0,p.useRef)(fe()),M=(0,p.useRef)(null),Ee=(0,p.useCallback)(async(f,S)=>{let I=M.current;if(I)try{await I}catch{}h([]),$(null),B(null),C(null),X(null),Y([]),Z(null),xe(f.max_steps),v(!0),w.current=null,b.current=0,U.current=fe();let y=x.current;if(y&&k.current!==f.session_id){try{y.kill()}catch{}x.current=null,k.current=null,A(n=>n+1),y=null}if(!y){let n=ne();if(!n){C("v16-runner not found. Build the binary with `cd v16-runner && python build.py` or ensure Python is available."),v(!1);return}let l=ie({environment:S?.environment,mode:S?.mode,assertionMode:S?.assertionMode,finalValidation:S?.finalValidation,username:f.username,accessKey:f.access_key,sessionId:f.session_id});f.device?.platform&&await re(l,f.device);let u=new F({env:l,runner:n,log:S?.log,sessionId:f.session_id,...S?.onRunnerEvent?{onEvent:S.onRunnerEvent}:{}});x.current=u,k.current=f.session_id,y=u,ee("runner",()=>{try{u.kill()}catch{}});let o={...f};z(o,{environment:S?.environment});let a=he(o);try{await u.start(a)}catch(t){C(t instanceof Error?t.message:String(t)),v(!1),j("runner","Runner start failed"),x.current=null,k.current=null,A(i=>i+1);return}}let q={...f};delete q.run_id,z(q,{environment:S?.environment});let je=`run-${f.run_index}`,Ne=f.mode==="replay"?"replay":"author",G=y,K=(async()=>{V.current=!1;for await(let n of G.run(je,Ne,q)){if(V.current)break;switch(U.current=Me(U.current,n),n.type){case"run_start":if(n.child_id)break;if(w.current&&!w.current.isSingleFlow){let l=b.current;b.current++,h(u=>u.map((o,a)=>a===l?{...o,status:"running"}:o.status==="running"&&!o.children?.some(t=>t.status==="running")?{...o,status:o.children?.some(t=>t.status==="failed")?"failed":"passed"}:o))}break;case"bifurcation":{let l=n.flows??[],u=n.count??l.length,o={flows:l,isSingleFlow:n.is_single_flow??u<=1};X(o),w.current=o,b.current=0,h(l.map((a,t)=>({index:t+1,objective:a??`Flow ${t+1}`,status:"pending"})));break}case"step_start":{e?.("STEP_START",`Step ${n.index} started`,{index:n.index,objective:n.objective,child_id:n.child_id});let l=n.index,u=n.objective??`Step ${l}`,o=n.child_id,a=w.current&&!w.current.isSingleFlow;if(o)h(t=>{let i=N(t,c=>c.branchChildId===o)??N(t,c=>c.status==="running");return i?T(t,i,c=>{let m=(c.children??[]).map(R=>R.status==="running"&&R.childId===o?{...R,status:"stopped",phase:void 0}:R);return m.push({index:l,objective:u,status:"running",childId:o}),{...c,children:m}}):t});else if(a){let t=Math.max(0,b.current-1);h(i=>{let c=[...i];if(t>=c.length)return i;let m={...c[t]},P=[...m.children??[]].map(O=>O.status==="running"&&O.childId===void 0?{...O,status:"stopped",phase:void 0}:O);return P.push({index:l,objective:u,status:"running"}),m.children=P,m.status="running",c[t]=m,c})}else h(t=>{let i=Q(t);return i.some(m=>m.index===l)?i.map(m=>m.index===l?{...m,status:"running",objective:u}:m):[...i,{index:l,objective:u,status:"running"}]});break}case"step_event":{e?.("STEP_EVENT",`Step ${n.index} ${n.event}`,{index:n.index,phase:n.event,action_type:n.action_type,detail:n.detail,child_id:n.child_id});let l=n.child_id,u=w.current&&!w.current.isSingleFlow;if(n.event==="cm_init"&&n.checkpoint_count!=null){Y(o=>[...o,n.checkpoint_count]);break}if(n.event==="replay_started"){Z({recordingLength:n.recording_length??0});break}if(n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&s?.(n.detail),l){let o=t=>{if(t.index!==n.index||t.childId!==l)return t;let i={phase:n.event};return n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(i.objective=n.detail),n.action_type&&(i.actionType=n.action_type),{...t,...i}},a=t=>t.map(i=>{let c=o(i);return c!==i?c:i.children&&i.children.length>0?{...i,children:a(i.children)}:i});h(t=>t.map(i=>i.children?{...i,children:a(i.children)}:i))}else if(u){let o=Math.max(0,b.current-1);h(a=>{let t=[...a];if(o>=t.length)return a;let i={...t[o]},c=[...i.children??[]];if(!c.some(R=>R.index===n.index&&R.childId===void 0))c.push({index:n.index,objective:`Step ${n.index}`,status:"running",phase:n.event,actionType:n.action_type});else for(let R=0;R<c.length;R++){if(c[R].index!==n.index||c[R].childId!==void 0)continue;let P={phase:n.event};n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(P.objective=n.detail),n.action_type&&(P.actionType=n.action_type),c[R]={...c[R],...P}}return i.children=c,t[o]=i,t})}else h(o=>o.some(t=>t.index===n.index)?o.map(t=>{if(t.index!==n.index)return t;let i={phase:n.event};return n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(i.objective=n.detail),n.action_type&&(i.actionType=n.action_type),{...t,...i}}):[...Q(o),{index:n.index,objective:`Step ${n.index}`,status:"running",phase:n.event,actionType:n.action_type}]);break}case"step_end":{e?.("STEP_END",`Step ${n.index} ${n.status}`,{index:n.index,status:n.status,duration:n.duration,summary:n.summary,child_id:n.child_id}),d?.();let l=n.child_id,u=w.current&&!w.current.isSingleFlow;if(l){let o=t=>t.index===n.index&&t.childId===l?{...t,status:n.status,duration:n.duration,phase:void 0,objective:t.objective.startsWith("Step ")?H(n.summary||t.objective):t.objective}:t,a=t=>t.map(i=>{let c=o(i);return c!==i?c:i.children&&i.children.length>0?{...i,children:a(i.children)}:i});h(t=>t.map(i=>i.children?{...i,children:a(i.children)}:i))}else if(u){let o=Math.max(0,b.current-1);h(a=>{let t=[...a];if(o>=t.length)return a;let i={...t[o]},c=(i.children??[]).map(m=>m.index===n.index&&m.childId===void 0?{...m,status:n.status,duration:n.duration,phase:void 0,objective:m.objective.startsWith("Step ")?H(n.summary||m.objective):m.objective}:m);return i.children=c,t[o]=i,t})}else h(o=>o.map(a=>a.index===n.index?{...a,status:n.status,duration:n.duration,phase:void 0,objective:a.objective.startsWith("Step ")?H(n.summary||a.objective):a.objective}:a));{let a=w.current&&!w.current.isSingleFlow?Math.max(0,b.current-1):0,t=typeof n.ordinal=="number"&&n.id?{ordinal:n.ordinal,id:n.id}:void 0;r?.(n.index,a,n.child_id,t)}break}case"child_agent_start":{let l=n.objective??"",u=n.child_id;h(o=>{let a=N(o,t=>t.status==="running");return a?T(o,a,t=>({...t,objective:`${l} (branch)`,phase:`child: ${l.slice(0,50)}`,branchObjective:l,branchChildId:u})):o});break}case"child_agent_end":{let l=n.child_id,u=`child ${n.success?"done":"failed"}`;h(o=>{let a=N(o,t=>t.branchChildId===l);return a?T(o,a,t=>({...t,phase:u})):o.map(t=>t.phase?.startsWith("child:")?{...t,phase:u}:t)});break}case"describe_trigger":g?.(n);break;case"ask_user":$(n.question??"");break;case"run_end":h(l=>l.map(u=>u.status==="running"?{...u,status:n.status,phase:void 0}:u)),v(!1),B(n);break;case"error":v(!1),C(n.message??"Runner error"),h(l=>l.map(u=>u.status==="running"?{...u,status:"failed",phase:void 0}:u));break}}})().catch(n=>{if(x.current!==G)return;let u=[n instanceof Error?n.message:String(n)],o=G.stderr;o&&!u.join(`
2
+ import{a as te,b as re,c as ie,d as se,e as z}from"./chunk-ULIIYKZB.js";import{b as oe,c as ae}from"./chunk-IINZZ4BZ.js";import{g as ne}from"./chunk-F2F257PU.js";import{n as ee,p as j}from"./chunk-UJLULWSR.js";import{a as De}from"./chunk-6YGTRKDT.js";import{e as $e}from"./chunk-UR6MHSHU.js";function Le(r){let e=r==="passed"?"passed":"failed";return{testStatus:e,remark:`kane-cli: ${e}`}}var Fe={testStatus:"failed",remark:"cancelled"};var Ae="https://www.testmuai.com/pricing/",Ue=/Real Mobile App Automation not allowed on your current plan/i,L=class extends Error{code="plan_required";constructor(e){super(e),this.name="RealDevicePlanError"}};function ue(r){return!r||!Ue.test(r)?null:["Real devices aren't included in your TestMu AI plan.","Running on a real device needs the KaneAI Max or Real Device Plus Automation Cloud plan.",`See plans: ${Ae}`].join(`
3
+ `)}function de(r){return{command:"start",...r}}function le(r,e,s){return{command:"run",run_id:r,kind:e,...s}}function ce(r){return{command:"cancel",...r?{run_id:r}:{}}}function pe(r){return{command:"ask_user_response",answer:r}}function he(r={}){return{command:"shutdown",...r.testStatus?{test_status:r.testStatus,remark:r.remark??""}:{}}}var W=Symbol("run-queue-end"),J=class{items=[];waiting=null;ended=!1;error=null;push(e){if(this.waiting){let{resolve:s}=this.waiting;this.waiting=null,s(e)}else this.items.push(e)}end(){if(this.ended=!0,this.waiting){let{resolve:e}=this.waiting;this.waiting=null,e(W)}}fail(e){if(this.error=e,this.waiting){let{reject:s}=this.waiting;this.waiting=null,s(e)}}next(){return this.items.length>0?Promise.resolve(this.items.shift()):this.error?Promise.reject(this.error):this.ended?Promise.resolve(W):new Promise((e,s)=>{this.waiting={resolve:e,reject:s}})}},F=class{env;runner;log;sessionId;spawnFn;proc=null;activeRun=null;pendingReady=null;shuttingDown=!1;finalized=!1;exitInfo=null;exitedUnexpectedly=!1;exitResolve;onEvent;exited;constructor(e){this.env=e.env,this.runner=e.runner,this.log=e.log,this.sessionId=e.sessionId,this.spawnFn=e.spawn??re,this.onEvent=e.onEvent;let s;this.exited=new Promise(d=>{s=d}),this.exitResolve=s}async start(e){if(this.proc)throw new Error("PersistentRunner.start called twice");this.proc=this.spawnFn({env:this.env,runner:this.runner,log:this.log,sessionId:this.sessionId}),this.consume();let s=new Promise((d,g)=>{this.pendingReady={resolve:d,reject:g}});this.writeCommand(de(e)),await s}async*run(e,s,d){if(!this.proc)throw new Error("PersistentRunner.run called before start");if(this.finalized)throw new Error(`v16-runner is not running (exited code=${this.exitInfo?.code??"null"}, signal=${this.exitInfo?.signal??"none"}) \u2014 cannot start run '${e}'`);if(this.activeRun)throw new Error(`PersistentRunner.run overlap: '${this.activeRun.runId}' still in flight`);let g=new J,_={runId:e,queue:g};this.activeRun=_,this.writeCommand(le(e,s,d));try{for(;;){let v=await g.next();if(v===W||(yield v,v.type==="run_end"&&(v.run_id===void 0||v.run_id===e)))break}}finally{this.activeRun===_&&(this.activeRun=null)}}sendUserResponse(e){this.writeCommand(pe(e))}cancel(e){this.writeCommand(ce(e))}kill(){this.proc?.child.kill("SIGTERM")}async shutdown(e={}){this.shuttingDown=!0,this.proc&&(this.writeCommand(he(e)),await this.exited)}get stderr(){return this.proc?.getStderr()??""}get diedUnexpectedly(){return this.exitedUnexpectedly}writeCommand(e){let s=JSON.stringify(e)+`
4
+ `;try{this.proc?.child.stdin?.write(s)}catch{}}async consume(){if(!this.proc)return;try{for await(let d of this.proc.events){if(d.type==="ready"){this.onReady();continue}if(d.type==="error"&&this.pendingReady){this.onStartError(d.message);continue}try{this.onEvent?.(d)}catch{}this.routeEvent(d)}}catch(d){this.log?.("error","PERSISTENT_RUNNER_STREAM_ERROR","Runner stdout stream errored",{error:d instanceof Error?d.message:String(d)})}let{code:e,signal:s}=await this.proc.exited;this.onExit(e,s)}onReady(){if(this.pendingReady){let{resolve:e}=this.pendingReady;this.pendingReady=null,e()}}onStartError(e){if(!this.pendingReady)return;let{reject:s}=this.pendingReady;this.pendingReady=null;let d=ue(e);if(d){this.log?.("error","REAL_DEVICE_PLAN_REQUIRED","The mobile hub refused the session over the plan",{reason:e}),s(new L(d));return}s(new Error(ne(e)??`failed to start: ${e??"unknown error"}`))}routeEvent(e){let s=this.activeRun;if(!s){this.log?.("warn","PERSISTENT_RUNNER_ORPHAN_EVENT","Runner event with no active run",{event_type:e.type});return}s.queue.push(e)}onExit(e,s){if(!this.finalized){if(this.finalized=!0,this.exitInfo={code:e,signal:s},this.shuttingDown||(this.exitedUnexpectedly=!0),this.exitResolve({code:e,signal:s}),this.pendingReady){let{reject:d}=this.pendingReady;this.pendingReady=null,d(new Error(`v16-runner exited before ready (code=${e}, signal=${s??"none"})`))}if(this.activeRun){let{queue:d}=this.activeRun;if(this.activeRun=null,this.shuttingDown)d.end();else{let g=this.proc?.getStderr()?.slice(-500)??"";d.fail(new Error(`v16-runner exited unexpectedly mid-run (code=${e}, signal=${s??"none"})${g?`
5
+ ${g}`:""}`))}}}}};var p=$e(De(),1);function fe(r){let e={cdp_endpoint:r.cdp_endpoint,ws_endpoint:r.ws_endpoint,width:r.width,height:r.height,headless:r.headless,model:r.model,max_steps:r.max_steps,network_ws:r.network_ws,network_sse:r.network_sse,session_id:r.session_id};return r.device&&(e.device=r.device),r.auth&&(e.auth=r.auth),r.project_id&&(e.project_id=r.project_id),r.disable_ask_user&&(e.disable_ask_user=!0),r.media_upload&&(e.media_upload=r.media_upload),r.username&&(e.username=r.username),r.access_key&&(e.access_key=r.access_key),e}function T(r,e){let s=null,d=(g,_)=>{for(let v=0;v<g.length;v++){let E=g[v],h=[..._,v];e(E)&&(s===null||h.length>s.length)&&(s=h),E.children&&E.children.length>0&&d(E.children,h)}};return d(r,[]),s}function N(r,e,s){if(e.length===0)return[...r];let d=e[0],g=[...r],_=g[d];if(e.length===1)g[d]=s(_);else{let v=e.slice(1),E=N(_.children??[],v,s);g[d]={..._,children:E}}return g}var Me=6e4;function me(){return{steps:[],maxOrdinal:0}}function Oe(r,e){if(e.type==="run_start"&&e.child_id)return e.environment?.resolution?{...r,resolution:e.environment.resolution}:r;if(e.type==="run_start"){let s=ae(r.runnerEnvironment,oe(e.environment));if(s)return{...r,runnerEnvironment:s,...s.resolution?{resolution:s.resolution}:{}}}if(e.type==="step_end"&&typeof e.ordinal=="number"&&e.id){let s={id:e.id,ordinal:e.ordinal,status:e.status,...e.kind?{kind:e.kind}:{},...typeof e.duration=="number"?{duration_ms:Math.round(e.duration*1e3)}:{},...typeof e.action_id=="string"&&e.action_id?{action_id:e.action_id}:{}};return{...r,steps:[...r.steps,s],maxOrdinal:Math.max(r.maxOrdinal,e.ordinal)}}return r}function H(r){let e=r.indexOf(": ");return e>0&&e<15?r.slice(e+2):r}function Q(r){return r.map(e=>{let s=e.children?Q(e.children):e.children;return e.status==="running"?{...e,status:"stopped",phase:void 0,children:s}:s!==e.children?{...e,children:s}:e})}function rn(r,e,s,d,g){let[_,v]=(0,p.useState)(!1),[E,h]=(0,p.useState)([]),[ve,$]=(0,p.useState)(null),[ge,B]=(0,p.useState)(null),[Re,C]=(0,p.useState)(null),[Se,X]=(0,p.useState)(null),[ye,Y]=(0,p.useState)([]),[we,Z]=(0,p.useState)(null),[xe,_e]=(0,p.useState)(void 0),[Ee,D]=(0,p.useState)(0),x=(0,p.useRef)(null),A=(0,p.useRef)(null),k=(0,p.useRef)(null),w=(0,p.useRef)(null),b=(0,p.useRef)(0),V=(0,p.useRef)(!1),U=(0,p.useRef)(me()),M=(0,p.useRef)(null),be=(0,p.useCallback)(async(f,S)=>{let I=M.current;if(I)try{await I}catch{}h([]),$(null),B(null),C(null),X(null),Y([]),Z(null),_e(f.max_steps),v(!0),w.current=null,b.current=0,U.current=me();let y=x.current;if(y&&k.current!==f.session_id){try{y.kill()}catch{}x.current=null,k.current=null,D(n=>n+1),y=null}if(!y){let n=te();if(!n){C("v16-runner not found. Build the binary with `cd v16-runner && python build.py` or ensure Python is available."),v(!1);return}let l=se({environment:S?.environment,mode:S?.mode,assertionMode:S?.assertionMode,finalValidation:S?.finalValidation,username:f.username,accessKey:f.access_key,sessionId:f.session_id});f.device?.platform&&await ie(l,f.device);let u=new F({env:l,runner:n,log:S?.log,sessionId:f.session_id,...S?.onRunnerEvent?{onEvent:S.onRunnerEvent}:{}});x.current=u,k.current=f.session_id,y=u,ee("runner",()=>{try{u.kill()}catch{}});let o={...f};z(o,{environment:S?.environment});let a=fe(o);try{await u.start(a)}catch(t){C(t instanceof Error?t.message:String(t)),v(!1),j("runner","Runner start failed"),x.current=null,k.current=null,D(i=>i+1);return}}let q={...f};delete q.run_id,z(q,{environment:S?.environment});let Te=`run-${f.run_index}`,Ne=f.mode==="replay"?"replay":"author",G=y,K=(async()=>{V.current=!1;for await(let n of G.run(Te,Ne,q)){if(V.current)break;switch(U.current=Oe(U.current,n),n.type){case"run_start":if(n.child_id)break;if(w.current&&!w.current.isSingleFlow){let l=b.current;b.current++,h(u=>u.map((o,a)=>a===l?{...o,status:"running"}:o.status==="running"&&!o.children?.some(t=>t.status==="running")?{...o,status:o.children?.some(t=>t.status==="failed")?"failed":"passed"}:o))}break;case"bifurcation":{let l=n.flows??[],u=n.count??l.length,o={flows:l,isSingleFlow:n.is_single_flow??u<=1};X(o),w.current=o,b.current=0,h(l.map((a,t)=>({index:t+1,objective:a??`Flow ${t+1}`,status:"pending"})));break}case"step_start":{e?.("STEP_START",`Step ${n.index} started`,{index:n.index,objective:n.objective,child_id:n.child_id});let l=n.index,u=n.objective??`Step ${l}`,o=n.child_id,a=w.current&&!w.current.isSingleFlow;if(o)h(t=>{let i=T(t,c=>c.branchChildId===o)??T(t,c=>c.status==="running");return i?N(t,i,c=>{let m=(c.children??[]).map(R=>R.status==="running"&&R.childId===o?{...R,status:"stopped",phase:void 0}:R);return m.push({index:l,objective:u,status:"running",childId:o}),{...c,children:m}}):t});else if(a){let t=Math.max(0,b.current-1);h(i=>{let c=[...i];if(t>=c.length)return i;let m={...c[t]},P=[...m.children??[]].map(O=>O.status==="running"&&O.childId===void 0?{...O,status:"stopped",phase:void 0}:O);return P.push({index:l,objective:u,status:"running"}),m.children=P,m.status="running",c[t]=m,c})}else h(t=>{let i=Q(t);return i.some(m=>m.index===l)?i.map(m=>m.index===l?{...m,status:"running",objective:u}:m):[...i,{index:l,objective:u,status:"running"}]});break}case"step_event":{e?.("STEP_EVENT",`Step ${n.index} ${n.event}`,{index:n.index,phase:n.event,action_type:n.action_type,detail:n.detail,child_id:n.child_id});let l=n.child_id,u=w.current&&!w.current.isSingleFlow;if(n.event==="cm_init"&&n.checkpoint_count!=null){Y(o=>[...o,n.checkpoint_count]);break}if(n.event==="replay_started"){Z({recordingLength:n.recording_length??0});break}if(n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&s?.(n.detail),l){let o=t=>{if(t.index!==n.index||t.childId!==l)return t;let i={phase:n.event};return n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(i.objective=n.detail),n.action_type&&(i.actionType=n.action_type),{...t,...i}},a=t=>t.map(i=>{let c=o(i);return c!==i?c:i.children&&i.children.length>0?{...i,children:a(i.children)}:i});h(t=>t.map(i=>i.children?{...i,children:a(i.children)}:i))}else if(u){let o=Math.max(0,b.current-1);h(a=>{let t=[...a];if(o>=t.length)return a;let i={...t[o]},c=[...i.children??[]];if(!c.some(R=>R.index===n.index&&R.childId===void 0))c.push({index:n.index,objective:`Step ${n.index}`,status:"running",phase:n.event,actionType:n.action_type});else for(let R=0;R<c.length;R++){if(c[R].index!==n.index||c[R].childId!==void 0)continue;let P={phase:n.event};n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(P.objective=n.detail),n.action_type&&(P.actionType=n.action_type),c[R]={...c[R],...P}}return i.children=c,t[o]=i,t})}else h(o=>o.some(t=>t.index===n.index)?o.map(t=>{if(t.index!==n.index)return t;let i={phase:n.event};return n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(i.objective=n.detail),n.action_type&&(i.actionType=n.action_type),{...t,...i}}):[...Q(o),{index:n.index,objective:`Step ${n.index}`,status:"running",phase:n.event,actionType:n.action_type}]);break}case"step_end":{e?.("STEP_END",`Step ${n.index} ${n.status}`,{index:n.index,status:n.status,duration:n.duration,summary:n.summary,child_id:n.child_id}),d?.();let l=n.child_id,u=w.current&&!w.current.isSingleFlow;if(l){let o=t=>t.index===n.index&&t.childId===l?{...t,status:n.status,duration:n.duration,phase:void 0,objective:t.objective.startsWith("Step ")?H(n.summary||t.objective):t.objective}:t,a=t=>t.map(i=>{let c=o(i);return c!==i?c:i.children&&i.children.length>0?{...i,children:a(i.children)}:i});h(t=>t.map(i=>i.children?{...i,children:a(i.children)}:i))}else if(u){let o=Math.max(0,b.current-1);h(a=>{let t=[...a];if(o>=t.length)return a;let i={...t[o]},c=(i.children??[]).map(m=>m.index===n.index&&m.childId===void 0?{...m,status:n.status,duration:n.duration,phase:void 0,objective:m.objective.startsWith("Step ")?H(n.summary||m.objective):m.objective}:m);return i.children=c,t[o]=i,t})}else h(o=>o.map(a=>a.index===n.index?{...a,status:n.status,duration:n.duration,phase:void 0,objective:a.objective.startsWith("Step ")?H(n.summary||a.objective):a.objective}:a));{let a=w.current&&!w.current.isSingleFlow?Math.max(0,b.current-1):0,t=typeof n.ordinal=="number"&&n.id?{ordinal:n.ordinal,id:n.id}:void 0;r?.(n.index,a,n.child_id,t)}break}case"child_agent_start":{let l=n.objective??"",u=n.child_id;h(o=>{let a=T(o,t=>t.status==="running");return a?N(o,a,t=>({...t,objective:`${l} (branch)`,phase:`child: ${l.slice(0,50)}`,branchObjective:l,branchChildId:u})):o});break}case"child_agent_end":{let l=n.child_id,u=`child ${n.success?"done":"failed"}`;h(o=>{let a=T(o,t=>t.branchChildId===l);return a?N(o,a,t=>({...t,phase:u})):o.map(t=>t.phase?.startsWith("child:")?{...t,phase:u}:t)});break}case"describe_trigger":g?.(n);break;case"ask_user":$(n.question??"");break;case"run_end":h(l=>l.map(u=>u.status==="running"?{...u,status:n.status,phase:void 0}:u)),v(!1),B(n);break;case"error":v(!1),C(n.message??"Runner error"),h(l=>l.map(u=>u.status==="running"?{...u,status:"failed",phase:void 0}:u));break}}})().catch(n=>{if(x.current!==G)return;let u=[n instanceof Error?n.message:String(n)],o=G.stderr;o&&!u.join(`
6
6
  `).includes(o)&&u.push(o),C(u.join(`
7
- `)),v(!1),h(a=>a.map(t=>t.status==="running"?{...t,status:"failed",phase:void 0}:t)),j("runner","Runner died mid-run"),x.current=null,k.current=null,A(a=>a+1)});M.current=K,K.finally(()=>{M.current===K&&(M.current=null)})},[r,e,s,d,g]),be=(0,p.useCallback)(f=>{x.current?.sendUserResponse(f),$(null)},[]),ke=(0,p.useCallback)(()=>{let f=x.current;f&&(f.cancel(),v(!1),$(null))},[]),Ie=(0,p.useCallback)((f,S)=>{if(D.current)return D.current;let I=x.current;if(!I)return Promise.resolve();let y=Ce(I,f,S?.timeoutMs).finally(()=>{D.current=null});return D.current=y,y},[]),Ce=async(f,S,I)=>{try{await Promise.race([f.shutdown(S??{}),new Promise(y=>setTimeout(y,I??(S?Ue:5e3)))])}catch{}j("runner","Runner shut down"),x.current=null,k.current=null,A(y=>y+1)},Pe=(0,p.useCallback)(()=>{h([]),B(null),C(null)},[]);return(0,p.useEffect)(()=>()=>{V.current=!0,j("runner","Component unmounted"),x.current=null,k.current=null},[]),{isRunning:_,steps:E,askingUser:me,lastRunEnd:ve,runError:ge,bifurcationInfo:Re,cmInitCounts:Se,replayInfo:ye,maxSteps:we,sessionGen:_e,startRun:Ee,sendAnswer:be,cancelRun:ke,shutdownRunner:Ie,clearLastRun:Pe,getEvidenceState:()=>U.current}}export{Oe as a,Le as b,F as c,he as d,fe as e,Me as f,nn as g};
7
+ `)),v(!1),h(a=>a.map(t=>t.status==="running"?{...t,status:"failed",phase:void 0}:t)),j("runner","Runner died mid-run"),x.current=null,k.current=null,D(a=>a+1)});M.current=K,K.finally(()=>{M.current===K&&(M.current=null)})},[r,e,s,d,g]),ke=(0,p.useCallback)(f=>{x.current?.sendUserResponse(f),$(null)},[]),Ie=(0,p.useCallback)(()=>{let f=x.current;f&&(f.cancel(),v(!1),$(null))},[]),Ce=(0,p.useCallback)((f,S)=>{if(A.current)return A.current;let I=x.current;if(!I)return Promise.resolve();let y=Pe(I,f,S?.timeoutMs).finally(()=>{A.current=null});return A.current=y,y},[]),Pe=async(f,S,I)=>{try{await Promise.race([f.shutdown(S??{}),new Promise(y=>setTimeout(y,I??(S?Me:5e3)))])}catch{}j("runner","Runner shut down"),x.current=null,k.current=null,D(y=>y+1)},je=(0,p.useCallback)(()=>{h([]),B(null),C(null)},[]);return(0,p.useEffect)(()=>()=>{V.current=!0,j("runner","Component unmounted"),x.current=null,k.current=null},[]),{isRunning:_,steps:E,askingUser:ve,lastRunEnd:ge,runError:Re,bifurcationInfo:Se,cmInitCounts:ye,replayInfo:we,maxSteps:xe,sessionGen:Ee,startRun:be,sendAnswer:ke,cancelRun:Ie,shutdownRunner:Ce,clearLastRun:je,getEvidenceState:()=>U.current}}export{Le as a,Fe as b,F as c,fe as d,me as e,Oe as f,rn as g};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as x}from"./chunk-HCBYKLMW.js";import{a,b as m,j as g}from"./chunk-33DWJV67.js";import{a as b}from"./chunk-6YGTRKDT.js";import{z as u}from"./chunk-QMOGBKJM.js";import{e as f}from"./chunk-UR6MHSHU.js";var T=f(b(),1);function k(i,n){if(!n)return i;let l=i.trim()||n;return`\x1B]8;;${n}\x07${l}\x1B]8;;\x07`}var r=f(x(),1);function $({shareableLink:i,testCaseLink:n,codeExportDir:l,recordedTestPath:s,outputDir:o,autoExit:p=!0}){let{exit:c}=g();(0,T.useEffect)(()=>{if(!p)return;let t=setTimeout(()=>c(),100);return()=>clearTimeout(t)},[c,p]);let e=[];return s&&e.push({label:"Test",url:s,linkUrl:`file://${s}`}),o&&e.push({label:"Output",url:o,linkUrl:`file://${o}`}),i&&e.push({label:"ShareLink",url:i}),n&&e.push({label:"TestCase",url:n}),l&&!o&&e.push({label:"CodeExport",url:l,linkUrl:`file://${l}`}),e.length===0?(0,r.jsx)(r.Fragment,{}):(0,r.jsx)(a,{flexDirection:"column",marginTop:1,marginLeft:1,children:e.map(t=>(0,r.jsxs)(a,{flexDirection:"column",marginBottom:1,children:[(0,r.jsxs)(m,{color:u.orange,children:[t.label,":"]}),(0,r.jsx)(m,{color:u.dim,children:k(t.url,t.linkUrl??t.url)})]},t.label))})}export{$ as a};
2
+ import{a as x}from"./chunk-HCBYKLMW.js";import{a,b as m,j as g}from"./chunk-33DWJV67.js";import{a as b}from"./chunk-6YGTRKDT.js";import{z as u}from"./chunk-J4FIESTB.js";import{e as f}from"./chunk-UR6MHSHU.js";var T=f(b(),1);function k(i,n){if(!n)return i;let l=i.trim()||n;return`\x1B]8;;${n}\x07${l}\x1B]8;;\x07`}var r=f(x(),1);function $({shareableLink:i,testCaseLink:n,codeExportDir:l,recordedTestPath:s,outputDir:o,autoExit:p=!0}){let{exit:c}=g();(0,T.useEffect)(()=>{if(!p)return;let t=setTimeout(()=>c(),100);return()=>clearTimeout(t)},[c,p]);let e=[];return s&&e.push({label:"Test",url:s,linkUrl:`file://${s}`}),o&&e.push({label:"Output",url:o,linkUrl:`file://${o}`}),i&&e.push({label:"ShareLink",url:i}),n&&e.push({label:"TestCase",url:n}),l&&!o&&e.push({label:"CodeExport",url:l,linkUrl:`file://${l}`}),e.length===0?(0,r.jsx)(r.Fragment,{}):(0,r.jsx)(a,{flexDirection:"column",marginTop:1,marginLeft:1,children:e.map(t=>(0,r.jsxs)(a,{flexDirection:"column",marginBottom:1,children:[(0,r.jsxs)(m,{color:u.orange,children:[t.label,":"]}),(0,r.jsx)(m,{color:u.dim,children:k(t.url,t.linkUrl??t.url)})]},t.label))})}export{$ as a};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as Be}from"./chunk-GGS3ATPB.js";import{a as Te}from"./chunk-252GEI3H.js";import{a as ce,b as Pe,c as Ue,d as ae,e as le,f as ue}from"./chunk-IZ65ZPWY.js";import{a as Ne,b as je}from"./chunk-63EKRZKI.js";import{c as Le,d as Ge}from"./chunk-6TNLITJO.js";import{g as Me}from"./chunk-4NUSW4A2.js";import{i as De}from"./chunk-LXM7VHYN.js";import{a as Ce}from"./chunk-AUJSC7PU.js";import{Ea as Re,Ia as $e,M as L,Na as Ie,Oa as Oe,e as be,sa as Ae,v as U}from"./chunk-Z777GGHB.js";import{e as ve,n as Se}from"./chunk-DBMW3VUN.js";import{g as xe}from"./chunk-KU3YHPWZ.js";import{a as Ee}from"./chunk-6NFOH4AC.js";import{m as ie}from"./chunk-4I7YN6YY.js";var ht=()=>null;function Zt(e){return e.telemetryIds?(e.provider??ht)({verb:e.verb,contextInstanceId:e.telemetryIds.context_instance_id??null,sessionId:e.telemetryIds.session_id}):e.storeLocalPath}function en(e,t){return e?t(e):"(no local trace)"}function nn(e){let t=process.env.HOME??"";return t&&e.startsWith(t)?`~${e.slice(t.length)}`:e}import{randomBytes as Ut}from"crypto";function de(e,t){let n=Math.min(e.length,t.length),s=0,r=0,c=0;for(let o=0;o<n;o++)s+=e[o]*t[o],r+=e[o]*e[o],c+=t[o]*t[o];return r===0||c===0?0:s/(Math.sqrt(r)*Math.sqrt(c))}function fe(e,t,n){return n*e+(1-n)*t}var ge=.7;var He=e=>e.lines!==void 0?[[e.lines[0],e.lines[1]]]:(e.segments??[]).map(([t,n])=>[t,n]);function Fe(e){let t=[];for(let[n,s]of He(e))for(let r=n;r<=s;r++)t.push(r);return t}function pt(e,t,n,s,r){let c=new Map(t.units.map(a=>[a.id,a]));if(r.some(a=>!c.has(a)))return null;let o=new Map;for(let a of e.units)r.includes(a.id)&&Fe(a).forEach((d,m)=>o.set(d,{unit:a,nth:m}));let g=new Map,u=[],f=!0;for(let a=n;a<=s&&f;a++){let d=o.get(a),m=d===void 0?void 0:c.get(d.unit.id);if(d===void 0||m===void 0||m.text!==d.unit.text){f=!1;break}let h=g.get(m.id);h===void 0&&g.set(m.id,h=Fe(m));let w=h[d.nth];w===void 0?f=!1:u.push(w)}return f&&u.length>0&&u.every((a,d)=>d===0||a===u[d-1]+1)?{anchor:`L${u[0]}-L${u[u.length-1]}`}:{units_at_head:r.flatMap(a=>He(c.get(a)).map(([d,m])=>({unit:a,anchor:`L${d}-L${m}`})))}}function Qe(e){let t=new Map,n=r=>{let c=e.mediaOf(r)?.plugin?.index;if(c===void 0)return null;let o=t.get(c);return o===void 0&&t.set(c,o=Se(e.getBlob(c))),o},s=new Map;return r=>{if(r.type!==xe.DERIVES||!Array.isArray(r.props.units)||r.props.units.length===0)return null;let c=r.props.units,o=e.headOf(String(r.props.source_id)),g=String(r.props.source_cid);if(o==null||o===g)return null;let u=s.get(o);u===void 0&&s.set(o,u=ve(o,w=>e.mediaOf(w)?.plugin));let f=u?.distance.get(g);if(u==null||f===void 0||c.some(w=>(u.touchedAt.get(w)??1/0)<=f))return null;let a=be(String(r.props.anchor));if(a?.kind!=="lines")return null;let d=n(g),m=n(o);if(d===null||m===null)return null;let h=pt(d,m,Math.min(a.a,a.b),Math.max(a.a,a.b),c);return h===null?null:{head:o,...h}}}var _t=["get_node","get_edges","find_by_provenance","match_by_type","stale_nodes","search_similar","search_similar_batch","history"],yt=["source_read","source_grep","source_list"],wt=[..._t,...yt],We=50,Xe=200,me=10,qe=50,Ve=20,kt=200,xt=50;function K(e,t,n){let s=typeof e=="number"&&Number.isFinite(e)?Math.floor(e):t;return Math.max(1,Math.min(s,n))}function M(e,t){let n=e[t];if(typeof n!="string"||n.length===0)throw new x(`param "${t}" must be a non-empty string`);return n}function O(e,t){let n=e[t];if(n==null)return null;if(typeof n!="string")throw new x(`param "${t}" must be a string when present`);return n}var x=class extends Error{},ze=24,bt=10,vt=10;function St(e){let t=e.cursor;if(t==null)return 0;if(typeof t=="string"&&/^\d+$/.test(t))return Number.parseInt(t,10);throw new x(`BAD_CURSOR: cursor ${JSON.stringify(t)} is not a cursor this store minted`)}function Ye(e,t){let n=t.fields;if(!Array.isArray(n)||n.length===0)return e;let s=new Set(n.filter(r=>typeof r=="string"));return e.map(r=>Object.fromEntries(Object.entries(r).filter(([c])=>s.has(c))))}function he(e,t,n=We,s=Xe){let r=St(t),c=K(t.limit,n,s),o=e.slice(r,r+c),g=r+o.length<e.length;return{rows:Ye(o,t),truncated:g,next_cursor:g?String(r+o.length):null}}var Et=e=>e.cursor!=null||e.fields!=null;function W(e,t,n=We){let s=he(e,t,n);return Et(t)||s.truncated?{rows:s.rows,truncated:s.truncated,next_cursor:s.next_cursor}:s.rows}function pe(e,t){let n=e.getNode(t);return n?{cid:t,label:n.label,content:n.content,trust:e.trust.get(t)??null,freshness:e.stale(t)}:null}function Ke(e){return new Set(e.toLowerCase().replace(/[^\p{L}\p{N}]+/gu," ").split(" ").filter(Boolean))}function X(e,...t){let n=Ke(e);if(n.size===0)return 0;let s=e.trim().toLowerCase(),r=0;for(let c of t){let o=Ke(c);if(o.size===0)continue;let g=0;for(let a of n)o.has(a)&&g++;let u=n.size+o.size-g,f=u===0?0:g/u;s&&c.toLowerCase().includes(s)&&(f=Math.max(f,.9)),r=Math.max(r,f)}return r}function At(e,t,n){let s=M(t,"cid"),r=O(t,"type"),c=O(t,"direction")??"both";if(!["out","in","both"].includes(c))throw new x('param "direction" must be out|in|both');let o=e.edgesFrom(s),g=e.edgesInto(s);if(o.length===0&&g.length===0&&!e.hasNode(s)&&![...e.heads.values()].includes(s))throw new x(`${s} names nothing in this project; read the cid again from where it was shown`);let u=[];(c==="out"||c==="both")&&u.push(...o),(c==="in"||c==="both")&&u.push(...g);let f=n===void 0?null:Qe({mediaOf:d=>e.mediaOf(d),getBlob:d=>n.getBlob(d),headOf:d=>e.heads.get(d)}),a=u.filter(d=>r==null||d.type===r).map(d=>{let m=f===null?null:f(d);return m===null?d:"anchor"in m?{...d,props:{...d.props,source_cid:m.head,anchor:m.anchor},pinned:{source_cid:d.props.source_cid,anchor:d.props.anchor}}:{...d,units_at_head:m.units_at_head}});return W(a,t)}function Rt(e,t){let n=M(t,"source_id"),s=e.heads.get(n)??null,r=[];for(let c of e.nodeLabel.keys()){let o=e.derivesInto(c).filter(u=>u.props.source_id===n).map(u=>({source_cid:u.props.source_cid,anchor:u.props.anchor??null}));if(o.length===0)continue;let g=pe(e,c);g&&r.push({...g,pins:o,pinned_to_head:s!=null&&o.some(u=>u.source_cid===s)})}return W(r,t,Xe)}function $t(e,t){let n=M(t,"label"),s=O(t,"trust"),r=O(t,"freshness"),c=[];for(let{cid:o}of e.byLabel(n)){let g=pe(e,o);g&&(s!=null&&g.trust!==s||r!=null&&g.freshness!==r||c.push(g))}return W(c,t)}function It(e,t={}){let n=O(t,"label"),s=e.staleList().map(({cid:r,state:c})=>{let o=e.getNode(r);return{cid:r,state:c,label:o?.label??null,title:o?.content.title??null}}).filter(r=>n==null||r.label===n);return W(s,t)}function Ot(e,t,n){let s=t.extracted,r=O(t,"kind"),c=[];for(let f of[...e.heads.keys()].sort()){let a=e.heads.get(f);if(typeof a!="string")continue;let m=e.mediaOf(a).format;if(r!=null&&m!==r)continue;let h=e.extractedSourceCids.has(a);if(typeof s=="boolean"&&h!==s)continue;let w=0;if(m!=="image"){let y=U(n,e,a);y&&(w=y.toString("utf8").replace(/\n$/,"").split(`
2
+ import{a as Be}from"./chunk-IZ66FKPC.js";import{a as Te}from"./chunk-GLM5UGTF.js";import{a as ce,b as Pe,c as Ue,d as ae,e as le,f as ue}from"./chunk-W5HFUBXD.js";import{a as Ne,b as je}from"./chunk-63EKRZKI.js";import{c as Le,d as Ge}from"./chunk-ZHAMVLQZ.js";import{g as Me}from"./chunk-SIHX5FW5.js";import{i as De}from"./chunk-X7S7IGCV.js";import{a as Ce}from"./chunk-FNUGDPTS.js";import{Ea as Re,Ia as $e,M as L,Na as Ie,Oa as Oe,e as be,sa as Ae,v as U}from"./chunk-PI7OXS62.js";import{e as ve,n as Se}from"./chunk-DBMW3VUN.js";import{g as xe}from"./chunk-KU3YHPWZ.js";import{a as Ee}from"./chunk-ZAQGIC33.js";import{o as ie}from"./chunk-HYJVYYAZ.js";var ht=()=>null;function Zt(e){return e.telemetryIds?(e.provider??ht)({verb:e.verb,contextInstanceId:e.telemetryIds.context_instance_id??null,sessionId:e.telemetryIds.session_id}):e.storeLocalPath}function en(e,t){return e?t(e):"(no local trace)"}function nn(e){let t=process.env.HOME??"";return t&&e.startsWith(t)?`~${e.slice(t.length)}`:e}import{randomBytes as Ut}from"crypto";function de(e,t){let n=Math.min(e.length,t.length),s=0,r=0,c=0;for(let o=0;o<n;o++)s+=e[o]*t[o],r+=e[o]*e[o],c+=t[o]*t[o];return r===0||c===0?0:s/(Math.sqrt(r)*Math.sqrt(c))}function fe(e,t,n){return n*e+(1-n)*t}var ge=.7;var He=e=>e.lines!==void 0?[[e.lines[0],e.lines[1]]]:(e.segments??[]).map(([t,n])=>[t,n]);function Fe(e){let t=[];for(let[n,s]of He(e))for(let r=n;r<=s;r++)t.push(r);return t}function pt(e,t,n,s,r){let c=new Map(t.units.map(a=>[a.id,a]));if(r.some(a=>!c.has(a)))return null;let o=new Map;for(let a of e.units)r.includes(a.id)&&Fe(a).forEach((d,m)=>o.set(d,{unit:a,nth:m}));let g=new Map,u=[],f=!0;for(let a=n;a<=s&&f;a++){let d=o.get(a),m=d===void 0?void 0:c.get(d.unit.id);if(d===void 0||m===void 0||m.text!==d.unit.text){f=!1;break}let h=g.get(m.id);h===void 0&&g.set(m.id,h=Fe(m));let w=h[d.nth];w===void 0?f=!1:u.push(w)}return f&&u.length>0&&u.every((a,d)=>d===0||a===u[d-1]+1)?{anchor:`L${u[0]}-L${u[u.length-1]}`}:{units_at_head:r.flatMap(a=>He(c.get(a)).map(([d,m])=>({unit:a,anchor:`L${d}-L${m}`})))}}function Qe(e){let t=new Map,n=r=>{let c=e.mediaOf(r)?.plugin?.index;if(c===void 0)return null;let o=t.get(c);return o===void 0&&t.set(c,o=Se(e.getBlob(c))),o},s=new Map;return r=>{if(r.type!==xe.DERIVES||!Array.isArray(r.props.units)||r.props.units.length===0)return null;let c=r.props.units,o=e.headOf(String(r.props.source_id)),g=String(r.props.source_cid);if(o==null||o===g)return null;let u=s.get(o);u===void 0&&s.set(o,u=ve(o,w=>e.mediaOf(w)?.plugin));let f=u?.distance.get(g);if(u==null||f===void 0||c.some(w=>(u.touchedAt.get(w)??1/0)<=f))return null;let a=be(String(r.props.anchor));if(a?.kind!=="lines")return null;let d=n(g),m=n(o);if(d===null||m===null)return null;let h=pt(d,m,Math.min(a.a,a.b),Math.max(a.a,a.b),c);return h===null?null:{head:o,...h}}}var _t=["get_node","get_edges","find_by_provenance","match_by_type","stale_nodes","search_similar","search_similar_batch","history"],yt=["source_read","source_grep","source_list"],wt=[..._t,...yt],We=50,Xe=200,me=10,qe=50,Ve=20,kt=200,xt=50;function K(e,t,n){let s=typeof e=="number"&&Number.isFinite(e)?Math.floor(e):t;return Math.max(1,Math.min(s,n))}function M(e,t){let n=e[t];if(typeof n!="string"||n.length===0)throw new x(`param "${t}" must be a non-empty string`);return n}function O(e,t){let n=e[t];if(n==null)return null;if(typeof n!="string")throw new x(`param "${t}" must be a string when present`);return n}var x=class extends Error{},ze=24,bt=10,vt=10;function St(e){let t=e.cursor;if(t==null)return 0;if(typeof t=="string"&&/^\d+$/.test(t))return Number.parseInt(t,10);throw new x(`BAD_CURSOR: cursor ${JSON.stringify(t)} is not a cursor this store minted`)}function Ye(e,t){let n=t.fields;if(!Array.isArray(n)||n.length===0)return e;let s=new Set(n.filter(r=>typeof r=="string"));return e.map(r=>Object.fromEntries(Object.entries(r).filter(([c])=>s.has(c))))}function he(e,t,n=We,s=Xe){let r=St(t),c=K(t.limit,n,s),o=e.slice(r,r+c),g=r+o.length<e.length;return{rows:Ye(o,t),truncated:g,next_cursor:g?String(r+o.length):null}}var Et=e=>e.cursor!=null||e.fields!=null;function W(e,t,n=We){let s=he(e,t,n);return Et(t)||s.truncated?{rows:s.rows,truncated:s.truncated,next_cursor:s.next_cursor}:s.rows}function pe(e,t){let n=e.getNode(t);return n?{cid:t,label:n.label,content:n.content,trust:e.trust.get(t)??null,freshness:e.stale(t)}:null}function Ke(e){return new Set(e.toLowerCase().replace(/[^\p{L}\p{N}]+/gu," ").split(" ").filter(Boolean))}function X(e,...t){let n=Ke(e);if(n.size===0)return 0;let s=e.trim().toLowerCase(),r=0;for(let c of t){let o=Ke(c);if(o.size===0)continue;let g=0;for(let a of n)o.has(a)&&g++;let u=n.size+o.size-g,f=u===0?0:g/u;s&&c.toLowerCase().includes(s)&&(f=Math.max(f,.9)),r=Math.max(r,f)}return r}function At(e,t,n){let s=M(t,"cid"),r=O(t,"type"),c=O(t,"direction")??"both";if(!["out","in","both"].includes(c))throw new x('param "direction" must be out|in|both');let o=e.edgesFrom(s),g=e.edgesInto(s);if(o.length===0&&g.length===0&&!e.hasNode(s)&&![...e.heads.values()].includes(s))throw new x(`${s} names nothing in this project; read the cid again from where it was shown`);let u=[];(c==="out"||c==="both")&&u.push(...o),(c==="in"||c==="both")&&u.push(...g);let f=n===void 0?null:Qe({mediaOf:d=>e.mediaOf(d),getBlob:d=>n.getBlob(d),headOf:d=>e.heads.get(d)}),a=u.filter(d=>r==null||d.type===r).map(d=>{let m=f===null?null:f(d);return m===null?d:"anchor"in m?{...d,props:{...d.props,source_cid:m.head,anchor:m.anchor},pinned:{source_cid:d.props.source_cid,anchor:d.props.anchor}}:{...d,units_at_head:m.units_at_head}});return W(a,t)}function Rt(e,t){let n=M(t,"source_id"),s=e.heads.get(n)??null,r=[];for(let c of e.nodeLabel.keys()){let o=e.derivesInto(c).filter(u=>u.props.source_id===n).map(u=>({source_cid:u.props.source_cid,anchor:u.props.anchor??null}));if(o.length===0)continue;let g=pe(e,c);g&&r.push({...g,pins:o,pinned_to_head:s!=null&&o.some(u=>u.source_cid===s)})}return W(r,t,Xe)}function $t(e,t){let n=M(t,"label"),s=O(t,"trust"),r=O(t,"freshness"),c=[];for(let{cid:o}of e.byLabel(n)){let g=pe(e,o);g&&(s!=null&&g.trust!==s||r!=null&&g.freshness!==r||c.push(g))}return W(c,t)}function It(e,t={}){let n=O(t,"label"),s=e.staleList().map(({cid:r,state:c})=>{let o=e.getNode(r);return{cid:r,state:c,label:o?.label??null,title:o?.content.title??null}}).filter(r=>n==null||r.label===n);return W(s,t)}function Ot(e,t,n){let s=t.extracted,r=O(t,"kind"),c=[];for(let f of[...e.heads.keys()].sort()){let a=e.heads.get(f);if(typeof a!="string")continue;let m=e.mediaOf(a).format;if(r!=null&&m!==r)continue;let h=e.extractedSourceCids.has(a);if(typeof s=="boolean"&&h!==s)continue;let w=0;if(m!=="image"){let y=U(n,e,a);y&&(w=y.toString("utf8").replace(/\n$/,"").split(`
3
3
  `).length)}let k=e.extractionCompleteness.get(f);c.push({source_id:f,kind:m,lines:w,head_cid:a,extracted:h,last_extract_at:k?.at??null,extractor_version:k?.extractor_version??null})}let{rows:o,truncated:g,next_cursor:u}=he(c,t);return{sources:o,truncated:g,next_cursor:u}}function Mt(e,t,n){let s=M(t,"ref"),r=e.resolve(s);if(!r)throw new x(`UNKNOWN_REF: ${s} names nothing in the graph`);let c=r.tip,o=new Map,g=v=>e.nodeLabel.get(v);for(let[v,A]of e.superseded)typeof A=="string"&&A!==v&&!Ae(v,A,g)&&o.set(A,[...o.get(A)??[],v]);let u=[],f=[c],a=new Set;for(;f.length>0;){let v=f.pop();a.has(v)||(a.add(v),u.push(v),f.push(...o.get(v)??[]))}let d=n.recordsSince(null),m=new Map,h=new Map;for(let v of d){for(let A of v.nodes)m.has(A.cid)||m.set(A.cid,v.ts);for(let A of v.supersessions)A.kind==="node"&&h.set(A.old,{by_cid:A.new,reason:A.reason})}let w=u.map(v=>({cid:v,minted_at:m.get(v)??null,superseded_by:h.get(v)?.by_cid??null,reason:h.get(v)?.reason??null,change_note:null})),{rows:k,truncated:y,next_cursor:D}=he(w,t,vt);return{root_logical_id:e.displayNameOf(c),live_tip:e.superseded.has(c)?null:c,truncated:y,next_cursor:D,chain:k}}function Je(e){let t=e.queries;if(!Array.isArray(t)||t.length<1||t.length>ze)throw new x(`param "queries" must be 1..${ze} entries`);return t.map((n,s)=>{if(typeof n!="object"||n===null)throw new x(`queries[${s}] must be an object`);let r=n;if(typeof r.qid!="string"||r.qid.length===0)throw new x(`queries[${s}].qid must be a non-empty string`);if(typeof r.text!="string"||r.text.length===0)throw new x(`queries[${s}].text must be a non-empty string`);return{qid:r.qid,text:r.text,topK:K(r.top_k,me,bt)}})}function Ze(e){let t=[];for(let{cid:n,content:s}of e.byLabel("usecase"))e.superseded.has(n)||t.push({cid:n,title:String(s.title??""),summary:String(s.summary??""),description:String(s.description??"")});return t}function et(e,t,n){let s=Ze(e);return t.map(r=>{let c=[];for(let o of s){let g=n(r,o);g<=0||c.push({cid:o.cid,logical_id:e.displayNameOf(o.cid),title:o.title,score:Math.round(g*1e3)/1e3,trust:e.trust.get(o.cid)??null,superseded:!1})}return c.sort((o,g)=>g.score-o.score||o.cid.localeCompare(g.cid)),{qid:r.qid,truncated:c.length>r.topK,matches:c.slice(0,r.topK)}})}function tt(e,t){let n=Je(t);return{results:et(e,n,(s,r)=>X(s.text,r.title,r.summary,r.description)),scorer:"lexical_fallback"}}function Dt(e,t){let n=M(t,"text"),s=O(t,"label")??"usecase",r=K(t.k,me,qe),c=[];for(let{cid:o,content:g}of e.byLabel(s)){let u=String(g.title??""),f=String(g.summary??""),a=X(n,u,f);a<=0||c.push({cid:o,title:u,summary:f,score:Math.round(a*1e3)/1e3,trust:e.trust.get(o)??null,freshness:e.stale(o)})}return c.sort((o,g)=>g.score-o.score||o.cid.localeCompare(g.cid)),c.slice(0,r)}function nt(e,t,n){let s=e.heads.get(n);if(typeof s!="string"){let c=[...e.heads.keys()].sort().join(", ");throw new x(`unknown source_id "${n}" \u2014 known: ${c||"(none)"}`)}if(e.mediaOf(s).format==="image")throw new x(`source "${n}" is an image \u2014 no line window (cite img#whole)`);let r=U(t,e,s);if(r==null)throw new x(`source "${n}" blob is missing from the store`);return{head:s,lines:r.toString("utf8").replace(/\n$/,"").split(`
4
4
  `)}}function Ct(e,t,n){return e.slice(t-1,n).map((s,r)=>`${String(t+r).padStart(4,"0")}| ${s}`).join(`
5
5
  `)}function Tt(e,t,n){let s=M(t,"source_id"),r=O(t,"anchor"),c=t.line_range;if(r!=null&&c!=null)throw new x("give anchor OR line_range, not both");let{head:o,lines:g}=nt(e,n,s),u=g.length,f,a;if(r!=null){let d=/^L(\d+)-L(\d+)$/.exec(r);if(!d)throw new x(`anchor "${r}" is not L<a>-L<b>`);let m=Number(d[1]),h=Number(d[2]);if(m<1||h<m||h>u)throw new x(`anchor "${r}" does not resolve (source has ${u} lines)`);f=Math.max(1,m-Ve),a=Math.min(u,h+Ve)}else if(c!=null){if(!Array.isArray(c)||c.length!==2||!c.every(h=>Number.isInteger(h)))throw new x('param "line_range" must be [from_line, to_line]');let[d,m]=c;if(d<1||m<d)throw new x('param "line_range" must be 1-based with from \u2264 to');if(d>u)throw new x(`line_range starts past the end (source has ${u} lines)`);f=d,a=Math.min(m,u)}else f=1,a=u;return a=Math.min(a,f+kt-1),{window:Ct(g,f,a),from_line:f,to_line:a,source_cid:o,total_lines:u}}function Lt(e,t,n){let s=M(t,"pattern"),r=O(t,"source_id"),c;try{c=new RegExp(s,"u")}catch(f){throw new x(`invalid pattern: ${f instanceof Error?f.message:String(f)}`)}let o=r!=null?[r]:[...e.heads.keys()].sort(),g=[],u=!1;e:for(let f of o){if(r==null){let d=e.heads.get(f);if(typeof d!="string"||e.mediaOf(d).format==="image")continue}let{lines:a}=nt(e,n,f);for(let d=0;d<a.length;d++)if(c.test(a[d])){if(g.length>=xt){u=!0;break e}g.push({source_id:f,line:d+1,text:a[d]})}}return{matches:g,truncated:u}}function Gt(e,t,n,s){try{switch(t){case"get_node":{let r=pe(e,M(n,"cid"));return r==null?{ok:!0,result:null}:{ok:!0,result:Ye([r],n)[0]}}case"get_edges":return{ok:!0,result:At(e,n,s)};case"find_by_provenance":return{ok:!0,result:Rt(e,n)};case"match_by_type":return{ok:!0,result:$t(e,n)};case"stale_nodes":return{ok:!0,result:It(e,n)};case"search_similar":return{ok:!0,result:Dt(e,n)};case"search_similar_batch":return{ok:!0,result:tt(e,n)};case"history":{if(s==null)throw new x("history unavailable (no context store)");return{ok:!0,result:Mt(e,n,s)}}case"source_list":{if(s==null)throw new x("source roster unavailable (no context store)");return{ok:!0,result:Ot(e,n,s)}}case"source_read":case"source_grep":{if(s==null)throw new x("source text unavailable (no context store)");return{ok:!0,result:(t==="source_read"?Tt:Lt)(e,n,s)}}default:return{ok:!1,error:`unknown method: ${t} \u2014 available: ${wt.join(", ")}`}}}catch(r){return r instanceof x?{ok:!1,error:`${t}: ${r.message}`}:{ok:!1,error:`${t}: graph read failed: ${r instanceof Error?r.message:String(r)}`}}}var I="assurance.sim";function Nt(e){return[e.title,e.summary,e.description].filter(Boolean).join(`
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as p}from"./chunk-GRURFGBP.js";import{a as g}from"./chunk-MYZHOBS4.js";import{existsSync as f}from"fs";import{isAbsolute as m,join as d,relative as v}from"path";function c(t){let n=f(d(t,".context"))?"assurance.json":"variables.json";return d(".testmuai","variables",n)}function h(t,n){if(!m(t))return t;let e=v(n,t);return e.startsWith("..")?t:e}function w(t,n){let e=t.used_by;if(e.length===0||e.every(s=>s.file===p))return"";if(n===void 0||!e.every(s=>s.file===n))return e.map(s=>`${s.file} step ${s.step}`).join(" \xB7 ");let a=[...new Set(e.map(s=>s.step))].sort((s,i)=>s-i);return a.length===1?`step ${a[0]}`:`steps ${a.join(", ")}`}function b(t,n){let e=new Map,a=new Map,s={header:"Not in any variables file",rows:[],declare:!0};for(let i of t){if(i.reason==="not_a_dataset_column"){let l=i.dataset??"",u=a.get(l);u||(u={header:`Not a column of dataset ${l}`.trimEnd(),rows:[],declare:!1},a.set(l,u)),u.rows.push(i);continue}if(i.reason!=="value_missing"){s.rows.push(i);continue}let r=h(i.file??c(n),n),o=e.get(r);o||(o={header:r===g?"Waiting for a value passed with --variables":`Waiting for a value in ${r}`,rows:[],declare:!1},e.set(r,o)),o.rows.push(i)}return[...e.values(),...a.values(),...s.rows.length>0?[s]:[]]}function $(t,n){let e=c(n);if(f(d(n,e)))return["",` Add ${t.length===1?"it":"them"} to ${e}`];let a=t.map(r=>`${JSON.stringify(r.name)}:`),s=Math.max(...a.map(r=>r.length))+1,i=a.map((r,o)=>` ${r.padEnd(s)}{ "value": "" }${o<a.length-1?",":""}`);return["",` Create ${e}:`,""," {",...i," }"]}function _(t,n){let e=t.length,a=`warning: ${e} variable${e===1?" has":"s have"} no value`,s=Math.max(...t.map(r=>r.name.length),8)+2,i=b(t,n.cwd).map(r=>{let o=[` ${r.header}`];for(let l of r.rows)o.push(` ${l.name.padEnd(s)}${w(l,n.entryFile)}`.trimEnd());return r.declare&&o.push(...$(r.rows,n.cwd)),o.join(`
2
+ import{a as p}from"./chunk-32MFECUA.js";import{a as g}from"./chunk-EHB55V23.js";import{existsSync as f}from"fs";import{isAbsolute as m,join as d,relative as v}from"path";function c(t){let n=f(d(t,".context"))?"assurance.json":"variables.json";return d(".testmuai","variables",n)}function h(t,n){if(!m(t))return t;let e=v(n,t);return e.startsWith("..")?t:e}function w(t,n){let e=t.used_by;if(e.length===0||e.every(s=>s.file===p))return"";if(n===void 0||!e.every(s=>s.file===n))return e.map(s=>`${s.file} step ${s.step}`).join(" \xB7 ");let a=[...new Set(e.map(s=>s.step))].sort((s,i)=>s-i);return a.length===1?`step ${a[0]}`:`steps ${a.join(", ")}`}function b(t,n){let e=new Map,a=new Map,s={header:"Not in any variables file",rows:[],declare:!0};for(let i of t){if(i.reason==="not_a_dataset_column"){let l=i.dataset??"",u=a.get(l);u||(u={header:`Not a column of dataset ${l}`.trimEnd(),rows:[],declare:!1},a.set(l,u)),u.rows.push(i);continue}if(i.reason!=="value_missing"){s.rows.push(i);continue}let r=h(i.file??c(n),n),o=e.get(r);o||(o={header:r===g?"Waiting for a value passed with --variables":`Waiting for a value in ${r}`,rows:[],declare:!1},e.set(r,o)),o.rows.push(i)}return[...e.values(),...a.values(),...s.rows.length>0?[s]:[]]}function $(t,n){let e=c(n);if(f(d(n,e)))return["",` Add ${t.length===1?"it":"them"} to ${e}`];let a=t.map(r=>`${JSON.stringify(r.name)}:`),s=Math.max(...a.map(r=>r.length))+1,i=a.map((r,o)=>` ${r.padEnd(s)}{ "value": "" }${o<a.length-1?",":""}`);return["",` Create ${e}:`,""," {",...i," }"]}function _(t,n){let e=t.length,a=`warning: ${e} variable${e===1?" has":"s have"} no value`,s=Math.max(...t.map(r=>r.name.length),8)+2,i=b(t,n.cwd).map(r=>{let o=[` ${r.header}`];for(let l of r.rows)o.push(` ${l.name.padEnd(s)}${w(l,n.entryFile)}`.trimEnd());return r.declare&&o.push(...$(r.rows,n.cwd)),o.join(`
3
3
  `)});return`${a}
4
4
 
5
5
  ${i.join(`
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{e as k,f as l}from"./chunk-Y6Y6RAY4.js";import{b as p}from"./chunk-PQXYHI5W.js";import{a as f}from"./chunk-GGV336P5.js";import{a as d}from"./chunk-RZ4F3BHX.js";import{promises as g}from"fs";import{basename as _,join as w}from"path";var D=3e3,S="/deviceSkin";function b(e){return e.replace(/\([^)]*\)/g," ").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||void 0}function v(e){if(e.model){let r=b(e.model);return r?`real-${r}`:void 0}let n=e.name?.trim();return n&&!k(n)?n:void 0}function y(e){let n=e?.data?.skin,r=typeof n?.skin_url=="string"?n.skin_url.trim():"",t=n?.skin_data??{},i=u=>typeof u=="number"&&Number.isFinite(u)?u:void 0,s=i(t.width),o=i(t.height);if(!r||!s||!o)return;let m={width:s,height:o};for(let u of["top","right","bottom","left","radius"]){let c=i(t[u]);c!==void 0&&(m[u]=c)}return{skin_url:r,skin_data:m}}var a=new Map;async function h(e,n,r={}){let t=`${f(e).lrmaaBaseUrl}${S}/${encodeURIComponent(n)}`;if(a.has(t))return a.get(t);try{let i=await(r.request??d)(t,{method:"GET",signal:AbortSignal.timeout(D)});if(!i.ok)return;let s=y(await i.json());return a.set(t,s),s}catch{return}}function A(e){let n=(e??"").trim().replace(/^lt:\/\//i,"").trim();if(n)return(p(n)?n:_(n))||void 0}async function P(e){try{let n=w(e,"steps"),r=(await g.readdir(n,{withFileTypes:!0})).filter(t=>t.isDirectory()).map(t=>t.name).sort((t,i)=>(parseInt(t,10)||0)-(parseInt(i,10)||0));for(let t of r)try{let i=await g.readFile(w(n,t,"step.json"),"utf8"),o=JSON.parse(i).basis?.window;if(Array.isArray(o)&&o.length===2&&Number.isFinite(Number(o[0]))&&Number.isFinite(Number(o[1]))&&Number(o[0])>0&&Number(o[1])>0)return`${Math.round(Number(o[0]))}x${Math.round(Number(o[1]))}`}catch{}return}catch{return}}async function T(e,n,r){if(!e.native_platform||!n.environment)return e;let t=v({model:n.deviceModel,name:l(n.runnerEnvironment?.device)});if(!t)return e;let i=await h(n.environment,t,r);return i?{...e,skin_url:i.skin_url,skin_data:i.skin_data}:e}export{v as a,h as b,A as c,P as d,T as e};
2
+ import{e as k,f as l}from"./chunk-WLEWXE6L.js";import{b as p}from"./chunk-LPJKNX6D.js";import{a as f}from"./chunk-ZCBOHWN3.js";import{a as d}from"./chunk-RZ4F3BHX.js";import{promises as g}from"fs";import{basename as _,join as w}from"path";var D=3e3,S="/deviceSkin";function b(e){return e.replace(/\([^)]*\)/g," ").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||void 0}function v(e){if(e.model){let r=b(e.model);return r?`real-${r}`:void 0}let n=e.name?.trim();return n&&!k(n)?n:void 0}function y(e){let n=e?.data?.skin,r=typeof n?.skin_url=="string"?n.skin_url.trim():"",t=n?.skin_data??{},i=u=>typeof u=="number"&&Number.isFinite(u)?u:void 0,s=i(t.width),o=i(t.height);if(!r||!s||!o)return;let m={width:s,height:o};for(let u of["top","right","bottom","left","radius"]){let c=i(t[u]);c!==void 0&&(m[u]=c)}return{skin_url:r,skin_data:m}}var a=new Map;async function h(e,n,r={}){let t=`${f(e).lrmaaBaseUrl}${S}/${encodeURIComponent(n)}`;if(a.has(t))return a.get(t);try{let i=await(r.request??d)(t,{method:"GET",signal:AbortSignal.timeout(D)});if(!i.ok)return;let s=y(await i.json());return a.set(t,s),s}catch{return}}function A(e){let n=(e??"").trim().replace(/^lt:\/\//i,"").trim();if(n)return(p(n)?n:_(n))||void 0}async function P(e){try{let n=w(e,"steps"),r=(await g.readdir(n,{withFileTypes:!0})).filter(t=>t.isDirectory()).map(t=>t.name).sort((t,i)=>(parseInt(t,10)||0)-(parseInt(i,10)||0));for(let t of r)try{let i=await g.readFile(w(n,t,"step.json"),"utf8"),o=JSON.parse(i).basis?.window;if(Array.isArray(o)&&o.length===2&&Number.isFinite(Number(o[0]))&&Number.isFinite(Number(o[1]))&&Number(o[0])>0&&Number(o[1])>0)return`${Math.round(Number(o[0]))}x${Math.round(Number(o[1]))}`}catch{}return}catch{return}}async function T(e,n,r){if(!e.native_platform||!n.environment)return e;let t=v({model:n.deviceModel,name:l(n.runnerEnvironment?.device)});if(!t)return e;let i=await h(n.environment,t,r);return i?{...e,skin_url:i.skin_url,skin_data:i.skin_data}:e}export{v as a,h as b,A as c,P as d,T as e};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as x}from"./chunk-DTYT6KBO.js";import{a as l}from"./chunk-HCBYKLMW.js";import{a as i,b as r}from"./chunk-33DWJV67.js";import{e}from"./chunk-UR6MHSHU.js";var o=e(l(),1);function m({title:c,state:t,rows:n}){return(0,o.jsxs)(i,{flexDirection:"column",marginTop:1,children:[(0,o.jsxs)(r,{children:[(0,o.jsx)(r,{bold:!0,children:c}),t?(0,o.jsx)(r,{color:t.color,children:` \u25CF ${t.text}`}):null]}),(0,o.jsx)(x,{rows:n,minWidth:20})]})}export{m as a};
2
+ import{b as x}from"./chunk-7Y55CO42.js";import{a as l}from"./chunk-HCBYKLMW.js";import{a as i,b as r}from"./chunk-33DWJV67.js";import{e}from"./chunk-UR6MHSHU.js";var o=e(l(),1);function m({title:c,state:t,rows:n}){return(0,o.jsxs)(i,{flexDirection:"column",marginTop:1,children:[(0,o.jsxs)(r,{children:[(0,o.jsx)(r,{bold:!0,children:c}),t?(0,o.jsx)(r,{color:t.color,children:` \u25CF ${t.text}`}):null]}),(0,o.jsx)(x,{rows:n,minWidth:20})]})}export{m as a};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as B}from"./chunk-436FZ4KG.js";import{b as N,f as d}from"./chunk-VQZOKTJ2.js";import{a as g,b as E}from"./chunk-KRRZCY7U.js";import{b as F,f as U,g as v}from"./chunk-QQI6N3FO.js";import{e as y,f as _}from"./chunk-ZKPY3AXW.js";import{d as C,e as O,i as x}from"./chunk-XMPTFXPW.js";import{C as h,Ha as c,f as R,r as P,w as S}from"./chunk-TLOYTGVT.js";import{a as w}from"./chunk-I2MC6VVX.js";async function I(e,r){let o=await r.project(e);return o===null?"no_access":o.marked?"marked":"unmarked"}var M=5e3;async function D(e,r=()=>!0){try{for(;;){if(!r())return{found:!1,failed:!0};let o=await e.next();if(o.done)return{found:!1};if(o.value.length>0)return{found:!0,rows:o.value}}}catch{return{found:!1,failed:!0}}}async function j(e,r={}){let o=await L(e,r.budgetMs??M);return o.state==="unknown"&&G(`shared projects weren't checked, so this folder goes on locally: ${o.reason}`),o}async function L(e,r){let o;try{o=await y()}catch(a){return a instanceof x?{state:"unknown",reason:"not signed in",signedOut:!0}:{state:"unknown",reason:"the credentials couldn't be read"}}let t,n=!1,s=new Promise(a=>{t=setTimeout(()=>{n=!0,a({state:"unknown",reason:`the project list took over ${r} ms`})},r)}),l=(async()=>{let a=R({url:e,basicAuth:o}).projects(),i=await D(a,()=>!n);return i.found?{state:"rolled_out",first:{rows:i.rows,more:a}}:i.failed?{state:"unknown",reason:"the project list couldn't be read"}:{state:"not_rolled_out"}})();try{return await Promise.race([l,s])}finally{clearTimeout(t)}}var G=g("remote-check");var T=e=>({code:e.code,message:e.message,...e.remedy?{remedy:e.remedy}:{}});async function A(e,r=_(e.latticeUrl)){let o;try{o=await I(e.projectId,r)}catch(t){if(t instanceof x)return T(t);if(t instanceof w&&t.retryable)return c.noConnection();if(t instanceof w&&t.status===401)return c.credentialsRejected();throw t}return o==="no_access"?c.noAccess(e.projectName):null}function H(e,r,o,t){if(e instanceof w){if(e.code==="SESSION_CLASH"&&t!==void 0&&h(e.extra.heldBy)!==null)return{...c.projectBusy({project:r.projectName,verb:t.verb==="evolve"?"design":t.verb,resume:o!==null,held:h(e.extra.heldBy),...t.useCase?{useCase:t.useCase}:{},...t.title!==void 0?{title:t.title}:{},...t.agent?{agent:!0}:{}}),exit:2};if(e.code==="MARK_REFUSED")return{...c.markRefused(r.projectName,r.onboarded===!0),exit:2};if(e.code==="PROJECT_NOT_MARKED")return{...c.assuranceOff(r.projectName),exit:2};if(e.retryable)return{...c.noConnectionAtStart(),exit:2};if(e.status===401)return{...c.credentialsRejected(),exit:2};if(e.code==="SESSION_ENDED")return{...$(e,o??""),exit:2};if(e.code==="NOT_FOUND"&&o!==null)return{...c.noSuchSession(o),exit:2};if(e.code==="FORMS_REFUSED")return{...J(e.extra)?c.versionCliOlder():c.versionServiceOlder(),exit:2}}else if(e instanceof B)return{...e.side==="cli_older"?c.versionCliOlder():c.versionServiceOlder(),exit:2};return{...c.openFailed(),exit:1}}function $(e,r){return e.extra.ended==="failed"?c.sessionFailed(r):c.sessionFinished(r)}function J(e){let r=typeof e.claimed=="number"?e.claimed:null;return r===null?!1:typeof e.oldestRead=="number"&&r<e.oldestRead?!0:typeof e.highestWriter=="number"&&e.highestWriter>r}async function fe(e,r,o,t={}){P({verb:e,mode:r?"agent":"interactive"});let n=await K(e,r,o,t);return n!==null&&"exit"in n&&await S(),n}async function K(e,r,o,t){let n=F(process.cwd()),s=e.split(" ").at(-1);if(t.project!==void 0||t.local===!0){let i=await W(n,e,s,r,{...t,...o!==void 0?{resume:o}:{}});if(i!=="undecided")return i}if(n.kind==="refuse")return{exit:d(n.refusal,s,r)};let l=n;if(n.kind==="pick"){if(o===void 0){if(!N.has(e)||!(!r&&C()&&t.onboard!==!1))return null;let u=await j(n.latticeUrl);if(u.state==="unknown"&&u.signedOut&&e==="context ingest"){let{signIn:m}=await import("./onboarding-ZP4XDYEO.js");if(await m()!=="signed_in")return null;u=await j(n.latticeUrl)}if(u.state!=="rolled_out")return null;let{onboard:k}=await import("./onboarding-ZP4XDYEO.js"),p=e==="context extract"?"context extract":"context ingest",f=await k(n,{first:u.first,verb:p});return"exit"in f?f:"local"in f?p==="context extract"&&f.made?{exit:0}:null:{choice:f.choice}}if((await j(n.latticeUrl)).state!=="rolled_out")return null;try{l=await V(n,o,await y())}catch(i){return i instanceof x?{exit:d(T(i),s,r)}:{exit:d(H(i,{kind:"remote",latticeUrl:n.latticeUrl,projectId:"",projectName:""},o),s,r)}}}if(l.kind!=="remote")return null;let a=await A(l);return a?{exit:d(a,s,r)}:{choice:l}}async function W(e,r,o,t,n){let[{decideFolderFlags:s},{personTms:l,workLocally:a}]=await Promise.all([import("./folder-flags-HTKJCXKB.js"),import("./onboarding-ZP4XDYEO.js")]),i=await s(e,{...n,agent:t},{getProject:async m=>(await l()).getProject(m)});if(i.kind==="none")return"undecided";if(i.kind==="refuse")return{exit:d(i.refusal,o,t)};let u=r==="context extract"?"context extract":"context ingest";if(i.kind==="local"){let m=a(u,{print:!t});if(!m.made)return null;if(t){let b=O("ndjson","extract");if(b.event({type:"folder_local",gitignore:m.gitignore}),u==="context extract")return{exit:b.done(0)}}return u==="context extract"?{exit:0}:null}if(n.notBuilt)return{exit:d(n.notBuilt,o,t)};let k=e;try{v(process.cwd(),{projectId:i.projectId,projectName:i.projectName,writtenBy:"kane-cli"})}catch(m){return g("remote-check")(`the folder's link couldn't be written: ${E(m)}`),{exit:d(c.projectFileUnwritable(U(process.cwd())),o,t)}}let p={kind:"remote",latticeUrl:k.latticeUrl,projectId:i.projectId,projectName:i.projectName,onboarded:!0},f=await A(p);return f?{exit:d(f,o,t)}:{choice:p}}async function V(e,r,o,t){let n=R({url:e.latticeUrl,basicAuth:o,...t?{fetch:t}:{}}),s=await n.getSession(r),l="";for await(let a of n.projects()){let i=a.find(u=>u.projectId===s.projectId);if(i){l=i.name;break}}return{kind:"remote",latticeUrl:e.latticeUrl,projectId:s.projectId,projectName:l}}export{A as a,H as b,$ as c,fe as d,V as e};
2
+ import{a as B}from"./chunk-JBKHX5ES.js";import{b as N,f as d}from"./chunk-4CJQ7XZP.js";import{a as g,b as E}from"./chunk-TAY7J5VS.js";import{b as F,f as U,g as v}from"./chunk-3RO2YGKH.js";import{e as y,f as _}from"./chunk-NI3TIAD7.js";import{d as C,e as O,i as x}from"./chunk-XMPTFXPW.js";import{C as h,Ha as c,f as R,r as P,w as S}from"./chunk-WE7HRAGO.js";import{a as w}from"./chunk-4C7WVQOD.js";async function I(e,r){let o=await r.project(e);return o===null?"no_access":o.marked?"marked":"unmarked"}var M=5e3;async function D(e,r=()=>!0){try{for(;;){if(!r())return{found:!1,failed:!0};let o=await e.next();if(o.done)return{found:!1};if(o.value.length>0)return{found:!0,rows:o.value}}}catch{return{found:!1,failed:!0}}}async function j(e,r={}){let o=await L(e,r.budgetMs??M);return o.state==="unknown"&&G(`shared projects weren't checked, so this folder goes on locally: ${o.reason}`),o}async function L(e,r){let o;try{o=await y()}catch(a){return a instanceof x?{state:"unknown",reason:"not signed in",signedOut:!0}:{state:"unknown",reason:"the credentials couldn't be read"}}let t,n=!1,s=new Promise(a=>{t=setTimeout(()=>{n=!0,a({state:"unknown",reason:`the project list took over ${r} ms`})},r)}),l=(async()=>{let a=R({url:e,basicAuth:o}).projects(),i=await D(a,()=>!n);return i.found?{state:"rolled_out",first:{rows:i.rows,more:a}}:i.failed?{state:"unknown",reason:"the project list couldn't be read"}:{state:"not_rolled_out"}})();try{return await Promise.race([l,s])}finally{clearTimeout(t)}}var G=g("remote-check");var T=e=>({code:e.code,message:e.message,...e.remedy?{remedy:e.remedy}:{}});async function A(e,r=_(e.latticeUrl)){let o;try{o=await I(e.projectId,r)}catch(t){if(t instanceof x)return T(t);if(t instanceof w&&t.retryable)return c.noConnection();if(t instanceof w&&t.status===401)return c.credentialsRejected();throw t}return o==="no_access"?c.noAccess(e.projectName):null}function H(e,r,o,t){if(e instanceof w){if(e.code==="SESSION_CLASH"&&t!==void 0&&h(e.extra.heldBy)!==null)return{...c.projectBusy({project:r.projectName,verb:t.verb==="evolve"?"design":t.verb,resume:o!==null,held:h(e.extra.heldBy),...t.useCase?{useCase:t.useCase}:{},...t.title!==void 0?{title:t.title}:{},...t.agent?{agent:!0}:{}}),exit:2};if(e.code==="MARK_REFUSED")return{...c.markRefused(r.projectName,r.onboarded===!0),exit:2};if(e.code==="PROJECT_NOT_MARKED")return{...c.assuranceOff(r.projectName),exit:2};if(e.retryable)return{...c.noConnectionAtStart(),exit:2};if(e.status===401)return{...c.credentialsRejected(),exit:2};if(e.code==="SESSION_ENDED")return{...$(e,o??""),exit:2};if(e.code==="NOT_FOUND"&&o!==null)return{...c.noSuchSession(o),exit:2};if(e.code==="FORMS_REFUSED")return{...J(e.extra)?c.versionCliOlder():c.versionServiceOlder(),exit:2}}else if(e instanceof B)return{...e.side==="cli_older"?c.versionCliOlder():c.versionServiceOlder(),exit:2};return{...c.openFailed(),exit:1}}function $(e,r){return e.extra.ended==="failed"?c.sessionFailed(r):c.sessionFinished(r)}function J(e){let r=typeof e.claimed=="number"?e.claimed:null;return r===null?!1:typeof e.oldestRead=="number"&&r<e.oldestRead?!0:typeof e.highestWriter=="number"&&e.highestWriter>r}async function fe(e,r,o,t={}){P({verb:e,mode:r?"agent":"interactive"});let n=await K(e,r,o,t);return n!==null&&"exit"in n&&await S(),n}async function K(e,r,o,t){let n=F(process.cwd()),s=e.split(" ").at(-1);if(t.project!==void 0||t.local===!0){let i=await W(n,e,s,r,{...t,...o!==void 0?{resume:o}:{}});if(i!=="undecided")return i}if(n.kind==="refuse")return{exit:d(n.refusal,s,r)};let l=n;if(n.kind==="pick"){if(o===void 0){if(!N.has(e)||!(!r&&C()&&t.onboard!==!1))return null;let u=await j(n.latticeUrl);if(u.state==="unknown"&&u.signedOut&&e==="context ingest"){let{signIn:m}=await import("./onboarding-6HIP3KW6.js");if(await m()!=="signed_in")return null;u=await j(n.latticeUrl)}if(u.state!=="rolled_out")return null;let{onboard:k}=await import("./onboarding-6HIP3KW6.js"),p=e==="context extract"?"context extract":"context ingest",f=await k(n,{first:u.first,verb:p});return"exit"in f?f:"local"in f?p==="context extract"&&f.made?{exit:0}:null:{choice:f.choice}}if((await j(n.latticeUrl)).state!=="rolled_out")return null;try{l=await V(n,o,await y())}catch(i){return i instanceof x?{exit:d(T(i),s,r)}:{exit:d(H(i,{kind:"remote",latticeUrl:n.latticeUrl,projectId:"",projectName:""},o),s,r)}}}if(l.kind!=="remote")return null;let a=await A(l);return a?{exit:d(a,s,r)}:{choice:l}}async function W(e,r,o,t,n){let[{decideFolderFlags:s},{personTms:l,workLocally:a}]=await Promise.all([import("./folder-flags-ZIDJVDKX.js"),import("./onboarding-6HIP3KW6.js")]),i=await s(e,{...n,agent:t},{getProject:async m=>(await l()).getProject(m)});if(i.kind==="none")return"undecided";if(i.kind==="refuse")return{exit:d(i.refusal,o,t)};let u=r==="context extract"?"context extract":"context ingest";if(i.kind==="local"){let m=a(u,{print:!t});if(!m.made)return null;if(t){let b=O("ndjson","extract");if(b.event({type:"folder_local",gitignore:m.gitignore}),u==="context extract")return{exit:b.done(0)}}return u==="context extract"?{exit:0}:null}if(n.notBuilt)return{exit:d(n.notBuilt,o,t)};let k=e;try{v(process.cwd(),{projectId:i.projectId,projectName:i.projectName,writtenBy:"kane-cli"})}catch(m){return g("remote-check")(`the folder's link couldn't be written: ${E(m)}`),{exit:d(c.projectFileUnwritable(U(process.cwd())),o,t)}}let p={kind:"remote",latticeUrl:k.latticeUrl,projectId:i.projectId,projectName:i.projectName,onboarded:!0},f=await A(p);return f?{exit:d(f,o,t)}:{choice:p}}async function V(e,r,o,t){let n=R({url:e.latticeUrl,basicAuth:o,...t?{fetch:t}:{}}),s=await n.getSession(r),l="";for await(let a of n.projects()){let i=a.find(u=>u.projectId===s.projectId);if(i){l=i.name;break}}return{kind:"remote",latticeUrl:e.latticeUrl,projectId:s.projectId,projectName:l}}export{A as a,H as b,$ as c,fe as d,V as e};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{g as f}from"./chunk-47WQBG5I.js";import{a as l}from"./chunk-KM3YCIDV.js";import{i as u}from"./chunk-G2KTWFMU.js";import{a as c}from"./chunk-JGLADDRH.js";import{f as s}from"./chunk-KF4DKXSS.js";import{c as p}from"./chunk-DPGOAFKF.js";import{b as i}from"./chunk-K3OSK6PB.js";async function E(n,o,e,t){let m=async()=>{let r=t.auth??{...await s(i),...t.telemetry?.spawnEnv()??{}};return u(e.sid!==void 0&&n.resume===void 0?{...n,sessionId:e.sid}:n,{store:o.store,pendingReconcilePlan:a=>o.dir===null?null:f(o.dir,a),agent:t.agent,tracePath:c,credentials:i,onIngestRefusal:l,preflightTurn:t.preflightTurn??(()=>p(r)),ask:async()=>[],review:async a=>new Map(a.map(d=>[d.temp_ref,{resolution:"skipped"}])),confirmStale:async()=>!1,out:e.out,...e.note?{note:e.note}:{},emit:e.emit,progress:e.progress,isTTY:!1,auth:r,...t.telemetry?{telemetry:t.telemetry}:{},...t.probe?{probe:t.probe}:{},...t.matchUnreviewed?{matchUnreviewed:!0}:{},...e.onSummary?{onSummary:e.onSummary}:{}})};if(!e.channel)return m();let{runWithChannel:g}=await import("./run-channel-63SVP5OI.js");return g({event:r=>e.emit(r)},m)}export{E as a};
2
+ import{g as f}from"./chunk-47WQBG5I.js";import{a as l}from"./chunk-KM3YCIDV.js";import{i as u}from"./chunk-X52YIWGG.js";import{a as c}from"./chunk-YNDELIXL.js";import{f as s}from"./chunk-CB344EDO.js";import{c as p}from"./chunk-GBQ4K25P.js";import{b as i}from"./chunk-EBJW6POT.js";async function E(n,o,e,t){let m=async()=>{let r=t.auth??{...await s(i),...t.telemetry?.spawnEnv()??{}};return u(e.sid!==void 0&&n.resume===void 0?{...n,sessionId:e.sid}:n,{store:o.store,pendingReconcilePlan:a=>o.dir===null?null:f(o.dir,a),agent:t.agent,tracePath:c,credentials:i,onIngestRefusal:l,preflightTurn:t.preflightTurn??(()=>p(r)),ask:async()=>[],review:async a=>new Map(a.map(d=>[d.temp_ref,{resolution:"skipped"}])),confirmStale:async()=>!1,out:e.out,...e.note?{note:e.note}:{},emit:e.emit,progress:e.progress,isTTY:!1,auth:r,...t.telemetry?{telemetry:t.telemetry}:{},...t.probe?{probe:t.probe}:{},...t.matchUnreviewed?{matchUnreviewed:!0}:{},...e.onSummary?{onSummary:e.onSummary}:{}})};if(!e.channel)return m();let{runWithChannel:g}=await import("./run-channel-IIIYXOIW.js");return g({event:r=>e.emit(r)},m)}export{E as a};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as h,b as x,c as O}from"./chunk-3AGP2BVN.js";import{oa as B}from"./chunk-Z777GGHB.js";import{a as S}from"./chunk-HCBYKLMW.js";import{b as i}from"./chunk-33DWJV67.js";import{a as w}from"./chunk-FOJHSG5M.js";import{z as s}from"./chunk-QMOGBKJM.js";import{e as L}from"./chunk-UR6MHSHU.js";var e=L(S(),1),W={high:0,med:1,low:2},E={high:s.red,med:"yellow",low:s.dim};function j(d){return d.map((n,o)=>({r:n,i:o})).sort((n,o)=>(W[n.r.risk??"zz"]??3)-(W[o.r.risk??"zz"]??3)||n.i-o.i).map(({r:n})=>n)}function z(d,n=120,o="risk"){if(d.length===0)return null;let a=j(d),l=t=>t.held?"(held)":t.staged||!t.id?"(staged)":B(t.id),p=Math.max(2,...a.map(t=>l(t).length)),g=o!==null,r=o!==null?Math.max(o.length,...a.map(t=>(t.badge??"").length)):0,m=n>=84&&a.some(t=>t.summary),c=2+(g?1:0)+(m?1:0),u=c+1+c*2,b=n-u-p-r,k=Math.max(...a.map(t=>Math.max(t.title.length,(t.marker??"").length)),5),f=Math.max(5,m?Math.min(k,Math.max(16,Math.floor(b*.5))):Math.min(k,b)),T=m?Math.max(7,b-f):0,R=(t,$,M,I)=>O(t,$,M,I.map(A=>A.length)),C=(t,$,M,I)=>[x(h(t,p),p),x(h($,f),f),...g?[x(h(M,r),r)]:[],...m?[x(h(I,T),T)]:[]],y=C("id","title",o??"","summary");return{showBadge:g,showSummary:m,headerCells:y,top:R("\u250C","\u252C","\u2510",y),middle:R("\u251C","\u253C","\u2524",y),bottom:R("\u2514","\u2534","\u2518",y),rows:a.map(t=>({cells:C(l(t),h(t.title,f),h(t.badge??"",r),h(t.summary??"",T)),badgeColor:t.badgeColor??E[t.badge??""]??s.dim,...t.marker?{markerCells:C("",h(t.marker,f),"","")}:{}}))}}function K(d,n){let o=z(d,n.width,n.badgeHeader===void 0?"risk":n.badgeHeader);if(o===null)return[];let a=(r,m)=>n.color?D(r,m):m,l=r=>a(s.dim,r),p=r=>n.color?w.bold(r):r,g=[l(o.top),`${l("\u2502 ")}${o.headerCells.map(p).join(l(" \u2502 "))}${l(" \u2502")}`,l(o.middle)];for(let r of o.rows){let[m,c,...u]=r.cells,b=o.showBadge?[a(r.badgeColor,u[0])]:[],k=o.showSummary?[u[o.showBadge?1:0]]:[];g.push(`${l("\u2502 ")}${a(s.assuranceAccent,m)}${l(" \u2502 ")}${[c,...b,...k].join(l(" \u2502 "))}${l(" \u2502")}`),r.markerCells&&g.push(l(`\u2502 ${r.markerCells.join(" \u2502 ")} \u2502`))}return g.push(l(o.bottom)),g}function D(d,n){if(d.startsWith("#"))return w.hex(d)(n);let o=w[d];return typeof o=="function"?o(n):n}function v({rows:d,width:n=120,badgeHeader:o="risk"}){let a=z(d,n,o);if(a===null)return null;let{showBadge:l,showSummary:p,headerCells:g}=a,r=[];r.push((0,e.jsx)(i,{color:s.dim,children:a.top},"t")),r.push((0,e.jsxs)(i,{children:[g.map((m,c)=>(0,e.jsxs)(i,{children:[(0,e.jsx)(i,{color:s.dim,children:c===0?"\u2502 ":" \u2502 "}),(0,e.jsx)(i,{bold:!0,children:m})]},c)),(0,e.jsx)(i,{color:s.dim,children:" \u2502"})]},"h")),r.push((0,e.jsx)(i,{color:s.dim,children:a.middle},"m"));for(let[m,c]of a.rows.entries()){let u=c.cells;r.push((0,e.jsxs)(i,{children:[(0,e.jsx)(i,{color:s.dim,children:"\u2502 "}),(0,e.jsx)(i,{color:s.assuranceAccent,children:u[0]}),(0,e.jsx)(i,{color:s.dim,children:" \u2502 "}),u[1],l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(i,{color:s.dim,children:" \u2502 "}),(0,e.jsx)(i,{color:c.badgeColor,children:u[2]})]}):null,p?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(i,{color:s.dim,children:" \u2502 "}),u[l?3:2]]}):null,(0,e.jsx)(i,{color:s.dim,children:" \u2502"})]},`r-${m}`)),c.markerCells&&r.push((0,e.jsx)(i,{color:s.dim,children:`\u2502 ${c.markerCells.join(" \u2502 ")} \u2502`},`mk-${m}`))}return r.push((0,e.jsx)(i,{color:s.dim,children:a.bottom},"b")),(0,e.jsx)(e.Fragment,{children:r})}export{K as a,v as b};
2
+ import{a as h,b as x,c as O}from"./chunk-3AGP2BVN.js";import{oa as B}from"./chunk-PI7OXS62.js";import{a as S}from"./chunk-HCBYKLMW.js";import{b as i}from"./chunk-33DWJV67.js";import{a as w}from"./chunk-FOJHSG5M.js";import{z as s}from"./chunk-J4FIESTB.js";import{e as L}from"./chunk-UR6MHSHU.js";var e=L(S(),1),W={high:0,med:1,low:2},E={high:s.red,med:"yellow",low:s.dim};function j(d){return d.map((n,o)=>({r:n,i:o})).sort((n,o)=>(W[n.r.risk??"zz"]??3)-(W[o.r.risk??"zz"]??3)||n.i-o.i).map(({r:n})=>n)}function z(d,n=120,o="risk"){if(d.length===0)return null;let a=j(d),l=t=>t.held?"(held)":t.staged||!t.id?"(staged)":B(t.id),p=Math.max(2,...a.map(t=>l(t).length)),g=o!==null,r=o!==null?Math.max(o.length,...a.map(t=>(t.badge??"").length)):0,m=n>=84&&a.some(t=>t.summary),c=2+(g?1:0)+(m?1:0),u=c+1+c*2,b=n-u-p-r,k=Math.max(...a.map(t=>Math.max(t.title.length,(t.marker??"").length)),5),f=Math.max(5,m?Math.min(k,Math.max(16,Math.floor(b*.5))):Math.min(k,b)),T=m?Math.max(7,b-f):0,R=(t,$,M,I)=>O(t,$,M,I.map(A=>A.length)),C=(t,$,M,I)=>[x(h(t,p),p),x(h($,f),f),...g?[x(h(M,r),r)]:[],...m?[x(h(I,T),T)]:[]],y=C("id","title",o??"","summary");return{showBadge:g,showSummary:m,headerCells:y,top:R("\u250C","\u252C","\u2510",y),middle:R("\u251C","\u253C","\u2524",y),bottom:R("\u2514","\u2534","\u2518",y),rows:a.map(t=>({cells:C(l(t),h(t.title,f),h(t.badge??"",r),h(t.summary??"",T)),badgeColor:t.badgeColor??E[t.badge??""]??s.dim,...t.marker?{markerCells:C("",h(t.marker,f),"","")}:{}}))}}function K(d,n){let o=z(d,n.width,n.badgeHeader===void 0?"risk":n.badgeHeader);if(o===null)return[];let a=(r,m)=>n.color?D(r,m):m,l=r=>a(s.dim,r),p=r=>n.color?w.bold(r):r,g=[l(o.top),`${l("\u2502 ")}${o.headerCells.map(p).join(l(" \u2502 "))}${l(" \u2502")}`,l(o.middle)];for(let r of o.rows){let[m,c,...u]=r.cells,b=o.showBadge?[a(r.badgeColor,u[0])]:[],k=o.showSummary?[u[o.showBadge?1:0]]:[];g.push(`${l("\u2502 ")}${a(s.assuranceAccent,m)}${l(" \u2502 ")}${[c,...b,...k].join(l(" \u2502 "))}${l(" \u2502")}`),r.markerCells&&g.push(l(`\u2502 ${r.markerCells.join(" \u2502 ")} \u2502`))}return g.push(l(o.bottom)),g}function D(d,n){if(d.startsWith("#"))return w.hex(d)(n);let o=w[d];return typeof o=="function"?o(n):n}function v({rows:d,width:n=120,badgeHeader:o="risk"}){let a=z(d,n,o);if(a===null)return null;let{showBadge:l,showSummary:p,headerCells:g}=a,r=[];r.push((0,e.jsx)(i,{color:s.dim,children:a.top},"t")),r.push((0,e.jsxs)(i,{children:[g.map((m,c)=>(0,e.jsxs)(i,{children:[(0,e.jsx)(i,{color:s.dim,children:c===0?"\u2502 ":" \u2502 "}),(0,e.jsx)(i,{bold:!0,children:m})]},c)),(0,e.jsx)(i,{color:s.dim,children:" \u2502"})]},"h")),r.push((0,e.jsx)(i,{color:s.dim,children:a.middle},"m"));for(let[m,c]of a.rows.entries()){let u=c.cells;r.push((0,e.jsxs)(i,{children:[(0,e.jsx)(i,{color:s.dim,children:"\u2502 "}),(0,e.jsx)(i,{color:s.assuranceAccent,children:u[0]}),(0,e.jsx)(i,{color:s.dim,children:" \u2502 "}),u[1],l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(i,{color:s.dim,children:" \u2502 "}),(0,e.jsx)(i,{color:c.badgeColor,children:u[2]})]}):null,p?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(i,{color:s.dim,children:" \u2502 "}),u[l?3:2]]}):null,(0,e.jsx)(i,{color:s.dim,children:" \u2502"})]},`r-${m}`)),c.markerCells&&r.push((0,e.jsx)(i,{color:s.dim,children:`\u2502 ${c.markerCells.join(" \u2502 ")} \u2502`},`mk-${m}`))}return r.push((0,e.jsx)(i,{color:s.dim,children:a.bottom},"b")),(0,e.jsx)(e.Fragment,{children:r})}export{K as a,v as b};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{c as y,e as k}from"./chunk-KF4DKXSS.js";import{spawn as A}from"child_process";var S=new Set(["progress","ask_user","graph_query","ingest_request","proposal","design","impact","error","done","reasoning_delta","reasoning_done","tool_activity","decision_activity","text_delta","usage","receipt","chat_ops","session_paused","session_complete","state_checkpoint","turn_retry"]),M=5e3,E=new Set(["done","session_paused","error"]);function R(u,t={}){let a=t.spawnCmd!==void 0?t.spawnCmd:y();if(!a)throw new Error("assurance agent not found \u2014 your platform package may be missing; reinstall kane-cli (npm i -g @testmuai/kane-cli)");let h=u.source.images?.length??0;a.tier==="dev-python"&&h>0&&t.onWarn?.("warn: development agent in use \u2014 if image citations are missing, update the agent package");let n=A(a.cmd,a.args,{stdio:["pipe","pipe","pipe"],env:k(u.session_id,t.auth)});if(n.stdin.on("error",e=>{e.code!=="EPIPE"&&t.onWarn?.(`agent stdin: ${e.message}`)}),n.stdin.write(JSON.stringify(u)+`
2
+ import{c as y,e as k}from"./chunk-CB344EDO.js";import{spawn as A}from"child_process";var S=new Set(["progress","ask_user","graph_query","ingest_request","proposal","design","impact","error","done","reasoning_delta","reasoning_done","tool_activity","decision_activity","text_delta","usage","receipt","chat_ops","session_paused","session_complete","state_checkpoint","turn_retry"]),M=5e3,E=new Set(["done","session_paused","error"]);function R(u,t={}){let a=t.spawnCmd!==void 0?t.spawnCmd:y();if(!a)throw new Error("assurance agent not found \u2014 your platform package may be missing; reinstall kane-cli (npm i -g @testmuai/kane-cli)");let h=u.source.images?.length??0;a.tier==="dev-python"&&h>0&&t.onWarn?.("warn: development agent in use \u2014 if image citations are missing, update the agent package");let n=A(a.cmd,a.args,{stdio:["pipe","pipe","pipe"],env:k(u.session_id,t.auth)});if(n.stdin.on("error",e=>{e.code!=="EPIPE"&&t.onWarn?.(`agent stdin: ${e.message}`)}),n.stdin.write(JSON.stringify(u)+`
3
3
  `),n.stdout.setEncoding("utf8"),n.stderr.setEncoding("utf8"),t.onStderr){let e="";n.stderr.on("data",r=>{e+=r;let i;for(;(i=e.indexOf(`
4
4
  `))>=0;){let o=e.slice(0,i);e=e.slice(i+1),o.trim()&&t.onStderr(o)}})}let g=!1,d=new Promise(e=>{n.on("exit",(r,i)=>{g=!0,e({code:r,signal:i})})}),p=null,f=()=>(p??=(async()=>{if(g||n.pid===void 0)return;n.kill("SIGTERM");let e=setTimeout(()=>{g||n.kill("SIGKILL")},t.killGraceMs??M);e.unref?.(),await d,clearTimeout(e)})(),p),l,v=()=>{l===void 0&&(l=setTimeout(()=>{f()},t.killGraceMs??M),l.unref?.())};d.then(()=>clearTimeout(l));async function*w(){let e="",r=!1;for await(let i of n.stdout){e+=i;let o;for(;(o=e.indexOf(`
5
5
  `))>=0;){let c=e.slice(0,o).trim();if(e=e.slice(o+1),!c)continue;let m;try{m=JSON.parse(c)}catch{t.onWarn?.(`agent: skipping malformed line: ${c.slice(0,120)}`);continue}let s=m;if(!s||typeof s!="object"||!S.has(s.type)){t.onWarn?.(`agent: skipping unknown event type "${s&&typeof s=="object"?String(s.type??"?"):"?"}"`);continue}if(E.has(s.type)&&v(),yield s,s.type==="done"){r=!0;break}}if(r)break}await d.catch(()=>{})}return{events:w(),send:e=>{n.stdin&&!n.stdin.destroyed&&n.stdin.write(JSON.stringify(e)+`
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as i}from"./chunk-ENG2UTMX.js";function c(t){let o=[];t.executionId&&o.push({label:"execution",kind:"execution",packPath:i(t.executionId,t.cwd),status:t.executionStatus??"passed"});for(let e of t.authored)e.executionId&&o.push({label:e.relPath,kind:"authored",packPath:i(e.executionId,t.cwd),status:e.overallStatus,...e.testId?{testId:e.testId}:{},...e.commitId?{commitId:e.commitId}:{},...e.sourceExecutionId?{sourceExecutionId:e.sourceExecutionId}:{}});return o}function s(t){return t.map(o=>`kane-cli evidence serve ${o.packPath} # ${o.kind==="authored"?`${o.label} (authored)`:o.label}`)}export{c as a,s as b};
2
+ import{b as i}from"./chunk-Z36KVIRR.js";function c(t){let o=[];t.executionId&&o.push({label:"execution",kind:"execution",packPath:i(t.executionId,t.cwd),status:t.executionStatus??"passed"});for(let e of t.authored)e.executionId&&o.push({label:e.relPath,kind:"authored",packPath:i(e.executionId,t.cwd),status:e.overallStatus,...e.testId?{testId:e.testId}:{},...e.commitId?{commitId:e.commitId}:{},...e.sourceExecutionId?{sourceExecutionId:e.sourceExecutionId}:{}});return o}function s(t){return t.map(o=>`kane-cli evidence serve ${o.packPath} # ${o.kind==="authored"?`${o.label} (authored)`:o.label}`)}export{c as a,s as b};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as Tr}from"./chunk-GI2JPIX5.js";import{a as dn,c as mn,e as Et,f as Je,g as $r,h as Rr,i as gn,j as Cr}from"./chunk-FVYIV36L.js";import{a as St,b as un}from"./chunk-AU26ZZTX.js";import{a as ln,b as wr}from"./chunk-RARD6TC6.js";import{a as xr,b as kr,c as vr}from"./chunk-JT6WLJSV.js";import{a as pr,b as ue}from"./chunk-7C4IEL5V.js";import{a as dr}from"./chunk-5Y2G4NC7.js";import{c as Rt}from"./chunk-SMXABALN.js";import{b as fr}from"./chunk-WN5VKKJ3.js";import{b as fn}from"./chunk-HD6NR44L.js";import{a as Ct,b as an,c as Ye,d as yr,e as cn}from"./chunk-BWXLZS5O.js";import{e as ze,f as S,g as br}from"./chunk-ZGQM6KWN.js";import{b as gr,c as Ge,d as hr}from"./chunk-22PIMG52.js";import{na as mr,oa as on}from"./chunk-Z777GGHB.js";import{a as ur}from"./chunk-WQR2GYP7.js";import{a as Y}from"./chunk-HCBYKLMW.js";import{a as w,b as r,k as Me}from"./chunk-33DWJV67.js";import{a as cr}from"./chunk-6YGTRKDT.js";import{z as o}from"./chunk-QMOGBKJM.js";import{e as U}from"./chunk-UR6MHSHU.js";var bn=U(cr(),1);var g=U(cr(),1);var m=U(Y(),1),Wi=60,Vi=100;function hn(e,s){let c=e.options.length,f=c,p=e.multi_select?f++:null,a=e.allow_free_text?f++:null,u=s?f++:null;return{optionCount:c,doneIdx:p,freeIdx:a,batchIdx:u,maxSel:f-1}}var Ki="\xA0",Ui={high:{text:`\u203C${Ki}high`,color:o.red},med:{text:"med",color:"yellow"},low:{text:"low",color:o.dim}};function Hi(e){let s=(e.header??e.text.split(/\s+/).slice(0,3).join(" ")).trim();return s.length>16?`${s.slice(0,15)}\u2026`:s}function Qi(e,s,c){let f=x=>e[x].length+6,p=f(s),a=s,u=s;for(;;){let x=u+1<e.length?f(u+1):1/0,y=a-1>=0?f(a-1):1/0;if(x===1/0&&y===1/0)break;if(x<=y){if(p+x>c)break;p+=x,u+=1}else{if(p+y>c)break;p+=y,a-=1}}return{lo:a,hi:u}}function Sr({batch:e,qView:s,sel:c=0,focused:f=!1,freeText:p=null,optionText:a=null,attach:u=null,multiSelFor:x,childPrefix:y,gapAbove:T=!0}){let{stdout:P}=Me(),V=P?.columns??80,re=V<Wi,C=Math.min(V-1,Vi),b=Math.max(0,Math.min(e.questions.length-1,s??(e.cursor<0?0:e.cursor))),I=e.questions[b],pe=e.resolution[b],q=e.resolution.filter(B=>!B).length,fe=e.questions.length-q,we=St(e),W=hn(I,we!==""),xe=x?x(b):[],ie=Ui[I.risk],Z=B=>f&&c===B?(0,m.jsx)(r,{color:o.assuranceAccent,children:"\u276F"}):" ",A=`? ${y??""}the agent needs ${q===1?"one answer":`${q} answers`}`,Pe=e.questions.length>1?` \xB7 ${b+1} of ${e.questions.length} \xB7 ${fe} answered`:"",H=(0,m.jsxs)(w,{flexDirection:"column",children:[(0,m.jsx)(w,{paddingLeft:2,children:(0,m.jsxs)(r,{bold:!0,children:[I.text,ie?(0,m.jsx)(r,{color:ie.color,bold:!1,children:` ${ie.text}`}):null]})}),(0,m.jsx)(w,{paddingLeft:2,children:(0,m.jsx)(r,{color:o.dim,children:I.rationale})}),(0,m.jsx)(r,{children:" "}),I.options.map((B,$)=>{let Q=f&&c===$;return a&&a.optionIndex===$?(0,m.jsx)(w,{flexDirection:"column",children:(0,m.jsxs)(w,{children:[(0,m.jsxs)(r,{children:[(0,m.jsx)(r,{color:o.assuranceAccent,children:"\u276F"})," ",(0,m.jsx)(r,{color:o.assuranceAccent,children:`${$+1}. ${un(B.label)}`}),(0,m.jsx)(r,{color:o.dim,children:" \u270E "})]}),(0,m.jsx)(Rt,{value:a.value,onChange:a.onChange,onSubmit:a.onSubmit,onCancel:a.onCancel,placeholder:B.detail||"type your answer"})]})},`o-${$}`):(0,m.jsxs)(w,{flexDirection:"column",children:[(0,m.jsxs)(r,{children:[Z($)," ",I.multi_select?(0,m.jsx)(r,{color:xe.includes($)?o.green:o.dim,children:xe.includes($)?"[x] ":"[ ] "}):null,(0,m.jsx)(r,{color:Q?o.assuranceAccent:void 0,children:`${$+1}. ${un(B.label)}`}),$===I.recommended_index?(0,m.jsx)(r,{color:o.dim,children:" (recommended)"}):null,pe?.selected_index===$?(0,m.jsx)(r,{color:o.dim,children:" (current)"}):null]}),B.detail?(0,m.jsx)(w,{paddingLeft:5,children:(0,m.jsx)(r,{color:o.dim,children:B.detail})}):null]},`o-${$}`)}),I.multi_select&&W.doneIdx!=null?(0,m.jsxs)(r,{children:[Z(W.doneIdx)," ",(0,m.jsx)(r,{color:o.green,children:"\u2714"}),(0,m.jsx)(r,{color:f&&c===W.doneIdx?o.assuranceAccent:void 0,children:" done \u2014 confirm selection"})]}):null,I.allow_free_text?(0,m.jsx)(r,{children:" "}):null,I.allow_free_text?p?(0,m.jsxs)(w,{children:[(0,m.jsxs)(r,{children:[(0,m.jsx)(r,{color:o.assuranceAccent,children:"\u276F"})," ",(0,m.jsx)(r,{color:o.dim,children:"\u270E "})]}),(0,m.jsx)(Rt,{value:p.value,onChange:p.onChange,onSubmit:p.onSubmit,onCancel:p.onCancel,placeholder:"Tell me what to do"})]}):(0,m.jsxs)(r,{children:[W.freeIdx!=null?Z(W.freeIdx):" "," ",(0,m.jsx)(r,{color:f&&W.freeIdx!=null&&c===W.freeIdx?o.assuranceAccent:o.dim,children:"\u270E Tell me what to do"})]}):null,u?(0,m.jsxs)(w,{flexDirection:"column",marginTop:1,children:[(0,m.jsxs)(w,{children:[(0,m.jsxs)(r,{children:[(0,m.jsx)(r,{color:o.assuranceAccent,children:"\u276F"})," ",(0,m.jsx)(r,{color:o.assuranceAccent,children:"@ attach a file or URL"}),(0,m.jsx)(r,{color:o.dim,children:" \u270E "})]}),(0,m.jsx)(Rt,{value:u.value,onChange:u.onChange,onSubmit:u.onSubmit,onCancel:u.onCancel,placeholder:"path or URL"})]}),(0,m.jsx)(w,{paddingLeft:2,children:(0,m.jsx)(r,{color:o.dim,children:"the questions are set aside \u2014 the agent reads the source and re-asks what's still open"})})]}):null]}),F=we!==""?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(r,{children:" "}),(0,m.jsxs)(r,{children:[f&&W.batchIdx!=null&&c===W.batchIdx?(0,m.jsx)(r,{color:o.assuranceAccent,children:"\u276F"}):" "," ",(0,m.jsx)(r,{color:o.assuranceAccent,children:"\xBB"}),(0,m.jsx)(r,{bold:!0,color:f&&W.batchIdx!=null&&c===W.batchIdx?o.assuranceAccent:void 0,children:" Go with recommendations"}),q>=5?(0,m.jsx)(r,{color:o.dim,children:` \u2014 resolves all ${q} open`}):null,(0,m.jsx)(r,{color:o.dim,children:" (tab)"})]})]}):null;if(re)return(0,m.jsxs)(w,{marginTop:T?1:0,marginBottom:1,flexDirection:"column",children:[(0,m.jsx)(r,{color:o.assuranceAccent,bold:!0,children:A}),e.questions.length>1?(0,m.jsx)(r,{color:o.dim,children:Pe.replace(/^ · /,"")}):null,(0,m.jsx)(r,{children:" "}),H,F]});let h=e.questions.map(B=>Hi(B)),me=e.questions.length>1?Qi(h,b,C-8):null;return(0,m.jsxs)(w,{marginTop:T?1:0,marginBottom:1,flexDirection:"column",children:[(0,m.jsxs)(r,{color:o.assuranceAccent,children:[(0,m.jsx)(r,{bold:!0,children:A}),Pe?(0,m.jsx)(r,{color:o.dim,children:Pe}):null]}),me?(0,m.jsx)(w,{marginTop:1,children:(0,m.jsxs)(r,{children:[me.lo>0?(0,m.jsx)(r,{color:o.dim,children:"\u25C0 "}):" ",e.questions.slice(me.lo,me.hi+1).map((B,$)=>{let Q=me.lo+$,et=$>0?" ":"";return Q===b?(0,m.jsxs)(r,{children:[et,(0,m.jsx)(r,{backgroundColor:o.assuranceAccent,color:"#0d1117",bold:!0,children:` ${h[Q]} `})]},B.id):(0,m.jsxs)(r,{children:[et,e.resolution[Q]?(0,m.jsxs)(r,{children:[(0,m.jsx)(r,{color:o.green,children:"\u2713 "}),(0,m.jsx)(r,{color:o.dim,children:h[Q]})]}):(0,m.jsx)(r,{color:o.dim,children:`\u25CB ${h[Q]}`})]},B.id)}),me.hi<e.questions.length-1?(0,m.jsx)(r,{color:o.dim,children:" \u25B6"}):null]})}):null,(0,m.jsx)(r,{children:" "}),H,F]})}var Er={ac:["acceptance criterion","acceptance criteria"],gap:["open question","open questions"],scenario:["scenario","scenarios"],test:["test","tests"],"use-case":["use-case","use-cases"]},pn=e=>Er[e]?.[1]??`${e}s`,At={label:(e,s)=>s===1?Er[e]?.[0]??e:pn(e),skip:new Set(["exercise"])},xn={ac:null,test:null,gap:null,scenario:"kind"},Xi=(e,s,c)=>`${e} ${e===1?s:c}`,Gi=e=>e.length<2?e.join(""):`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`;function Ar(e){let s=e.covers?on(e.covers):"1 scenario",c=e.verifies.slice(0,2).map(on),f=e.verifiesTotal-c.length,p=c.length===0?Xi(e.verifiesTotal,"acceptance criterion","acceptance criteria"):Gi([...c,...f>0?[`${f} more`]:[]]);return`covers ${s} \xB7 verifies ${p}`}function Dr(e,s){let c=typeof s=="string"&&s!==""?s.split(", "):[],f=p=>typeof p=="string"&&mr.test(p);return{covers:f(e)?e:null,verifies:c.filter(f),verifiesTotal:c.length}}var Dt={"acceptance criteria":{name:"acceptance criteria",next:"scenarios",done:"acceptance criteria say what the use-case must always do"},scenarios:{name:"scenarios",next:"scenario checks",done:"scenarios are the paths a user takes that test the criteria"},"acceptance criteria + exercises":{name:"scenario checks",next:"tests",done:"scenario checks say which criteria each scenario checks"},"tests + gaps":{name:"tests"},tests:{name:"tests"}};function Ze(e){let s=Dt[e]?.name;if(s)return s;let c={exercises:"scenario checks",gaps:"open questions"};return[...new Set(e.split(" + ").map(f=>c[f]??f))].join(" + ")}var Ir={scenarios:"next, scenarios: the paths a user takes that test them","scenario checks":"next, scenario checks: which criteria each scenario checks",tests:"next, tests: runnable tests, and open questions for what can't run"},Br="phases: acceptance criteria \u2192 scenarios \u2192 scenario checks \u2192 tests";var k=U(Y(),1),zi=e=>e.startsWith("designing: ")?`designing: ${Ze(e.slice(11))}`:e;function Yi(e,s){let c=e.form==="assumed"?" (assumed)":e.form==="deferred"?"":" (you)",f=e.note?` \u2014 ${e.note}`:"",p=s?`"${e.stub}"`:`q${e.qNum} ${e.stub}`;return e.form==="deferred"?`\u21B3 deferred ${p}${f}`:e.form==="changed"?`\u21B3 changed ${p}: ${e.prev??"?"} \u2192 ${e.choice??"?"}${c}${f}`:`\u21B3 ${e.form} ${p}: ${e.choice??"?"}${c}${f}`}var Ji=()=>(process.stdout?.columns??100)-12,Zi=new Set(["banner","header","user","agent","worked","childOpen","lines"]);function Lr({block:e,annotations:s,remote:c=!1,afterHeader:f=!1}){let p=e.era??0,{stdout:a}=Me(),u=c||p>0?(a?.columns??100)-p*2:null,x=ns(e,s??null,c,u,(a?.columns??100)-p*2),y=p>0?(0,k.jsx)(w,{marginLeft:p*2,children:x}):x;return f&&!Zi.has(e.kind)?(0,k.jsx)(w,{marginTop:1,children:y}):y}var es=new RegExp("[\\u1100-\\u115F\\u2E80-\\u303E\\u3041-\\uA4CF\\uAC00-\\uD7A3\\uF900-\\uFAFF\\uFE10-\\uFE19\\uFE30-\\uFE6F\\uFF00-\\uFF60\\uFFE0-\\uFFE6\\u{20000}-\\u{3FFFD}\u2714\u26A0]|\\p{Emoji_Presentation}","u"),It=e=>[...e].reduce((s,c)=>s+(es.test(c)?2:1),0);function ts(e,s,c){let f=Math.max(12,c-It(e)),p=[],a="";for(let u of s){let x=a?`${a} \xB7 ${u}`:u;It(x)>f&&a?(p.push(a),a=u):a=x}return p.push(a),p.map((u,x)=>(x===0?e:" ".repeat(e.length))+u)}function _e(e,s,c){let f=Math.max(12,c-It(e)),p=[],a="";for(let u of s.split(" ")){let x=a?`${a} ${u}`:u;It(x)>f&&a?(p.push(a),a=u):a=x}return p.push(a),p.map((u,x)=>(x===0?e:" ".repeat(e.length))+u)}function ns(e,s,c,f=null,p=100){switch(e.kind){case"banner":return(0,k.jsx)(w,{marginTop:1,children:(0,k.jsx)(r,{bold:!0,color:o.assuranceAccent,children:` ${c?zi(e.text):e.text}`})});case"header":return(0,k.jsx)(w,{marginTop:1,children:(0,k.jsxs)(r,{color:o.assuranceAccent,children:[`\u25CF ${e.text}`,e.tail?(0,k.jsx)(r,{color:o.dim,children:` \u2014 ${e.tail}`}):null]})});case"user":return(0,k.jsxs)(w,{marginTop:1,children:[(0,k.jsx)(r,{color:o.orange,children:"\u276F "}),(0,k.jsx)(r,{children:e.text})]});case"note":return(0,k.jsx)(r,{color:o.dim,children:` ${e.text}`});case"lines":return(0,k.jsx)(w,{flexDirection:"column",marginTop:1,children:e.lines.map((a,u)=>(0,k.jsx)(r,{...a.dim?{color:o.dim}:{},children:a.text},u))});case"agent":return(0,k.jsx)(w,{marginTop:1,children:(0,k.jsx)(kr,{text:e.text,accent:o.assuranceAccent,indent:f===null?0:(e.era??0)*2})});case"worked":return(0,k.jsx)(w,{marginTop:1,flexDirection:"column",children:ts(" \u2699 ",hr(e.durS,e.toolCalls,e.tools),p).map((a,u)=>(0,k.jsx)(r,{color:o.dim,children:a},u))});case"usage":return(0,k.jsx)(r,{color:o.dim,children:` \xB7 ${e.credits.toFixed(1)} credits \u2014 total ${e.total.toFixed(1)}`});case"turn":{let a=s,u=(a?a.fresh:e.items.map((C,b)=>({item:C,num:b+1,updated:!1}))).filter(C=>!(c&&At.skip?.has(C.item.kind??""))),x={usecase:"risk","use-case":"risk",ac:"check",scenario:"kind",test:"check",gap:"risk",stylenote:"kind"},y=C=>C.kind??"use-case",T=new Map;for(let C of u){let b=C.item,I=y(C.item),pe=c&&I==="test"?{title:b.title,summary:Ar(b.links??Dr(b.extra?.automates,b.extra?.verifies)),badge:""}:c&&I==="gap"?{title:b.question??"",summary:b.rationale??"",badge:""}:null,q=b.risk==="high"||b.risk==="med"||b.risk==="low"?b.risk:void 0,fe=b.logical_id??(c?b.matched_id:void 0),we={id:fe??"",staged:!fe,...c&&b.held&&!fe?{held:!0}:{},title:pe?.title??b.title,badge:pe?.badge??b.badge??b.risk??"",summary:pe?.summary??b.why??b.summary??b.description??"",...q?{risk:q}:{},...C.updated?{marker:"\u21B3 changed"}:{}},W=T.get(I)??[];W.push(we),T.set(I,W)}let P=u.some(C=>!!C.item.kind),V=(a?.unchanged??[]).reduce((C,b)=>C+b.count,0),re=a?.headerStats?` \u2014 ${a.headerStats}${V>0?` (${V} unchanged)`:""}`:"";return(0,k.jsxs)(w,{flexDirection:"column",marginLeft:2,children:[(0,k.jsxs)(r,{bold:!0,children:[P?"design":e.heading,re?(0,k.jsx)(r,{bold:!1,color:o.dim,children:re}):null]}),[...T.entries()].map(([C,b])=>(0,k.jsxs)(w,{flexDirection:"column",children:[T.size>1?(0,k.jsx)(r,{color:o.dim,children:`${c?pn(C):Ct(C)} \xB7 ${b.length}`}):null,(0,k.jsx)(Tr,{rows:b,width:Ji(),badgeHeader:c&&C in xn?xn[C]:x[C]??"info"})]},C)),a&&a.unchanged.length>0&&(0,k.jsx)(r,{color:o.dim,children:` \u22EE unchanged: ${a.unchanged.map(C=>`${C.count} ${C.label}`).join(" \xB7 ")}`})]})}case"answer":return(0,k.jsx)(r,{color:o.dim,children:Yi(e.receipt,c)});case"continued":return(0,k.jsx)(r,{color:o.dim,children:"\u21B3 continued"});case"childOpen":{if(c)return(0,k.jsx)(w,{marginTop:1,children:(0,k.jsx)(r,{color:o.assuranceAccent,children:`\u25CF ${e.update?S.updateOpen(e.subject,e.changed===!0):S.childOpen(e.verb,e.subject)}`})});let{ing:a}=fn(e.verb);return(0,k.jsx)(w,{marginTop:1,children:(0,k.jsxs)(r,{color:o.assuranceAccent,children:[`\u25CF ${a} ${e.subject}`,e.sid?(0,k.jsx)(r,{color:o.dim,children:` \u2014 ${e.sid}`}):null,e.note?(0,k.jsx)(r,{color:o.dim,children:` ${e.note}`}):null]})})}case"childClose":{if(e.held)return(0,k.jsx)(w,{});if(c&&e.update){let x=[Ge(e.durS),...e.credits!==void 0?[`${e.credits.toFixed(1)} credits`]:[]];if(!e.ok)return(0,k.jsx)(r,{color:o.red,children:`\u25CF ${S.updateFailed(e.subject)}`});if(e.untouched)return(0,k.jsx)(r,{children:`\u25CF ${S.updateUntouched(e.subject)} \u2014 ${x.join(" \xB7 ")}`});if(e.unfinished)return(0,k.jsx)(r,{children:`\u25CF ${S.updateUnfinished(e.subject)} \u2014 ${x.join(" \xB7 ")}`});let y=e.testsWritten?S.updateTests(e.testsWritten):null,T=[x[0],...y?[y]:[],...x.slice(1)];return(0,k.jsx)(r,{color:o.green,children:`\u25CF ${S.updateClosed(e.subject,T)}`})}if(c){if(!e.ok)return(0,k.jsx)(r,{color:o.red,children:`\u25CF ${S.childFailed(e.verb,e.subject)}`});if(e.unfinished)return(0,k.jsx)(r,{children:`\u25CF ${[S.childUnfinished(e.verb),[Ge(e.durS),...e.credits!==void 0?[`${e.credits.toFixed(1)} credits`]:[]].join(" \xB7 ")].join(" \u2014 ")}`});let x=[Ge(e.durS),...e.tests?[S.childTests(e.verb,e.tests)]:[],...e.credits!==void 0?[`${e.credits.toFixed(1)} credits`]:[]];return(0,k.jsx)(r,{color:o.green,children:`\u25CF ${S.childClosed(e.verb,e.subject,x)}`})}let{ed:a}=fn(e.verb);if(!e.ok)return(0,k.jsxs)(r,{color:o.red,children:[`\u25CF ${e.verb} failed \u2014 ${e.exitCode!=null?`exited ${e.exitCode}`:"error"}`,e.fixCmd?(0,k.jsx)(r,{color:o.dim,children:` \xB7 ${e.fixCmd}`}):null]});let u=[Ge(e.durS),...e.results?[e.results]:[],...e.credits!==void 0?[`${e.credits.toFixed(1)} credits`]:[]].join(" \xB7 ");return(0,k.jsx)(r,{color:o.green,children:`\u25CF ${a} ${e.subject} \u2014 ${u}`})}case"childBack":return(0,k.jsx)(r,{color:o.dim,children:`back with ${e.parentVerb} \u2014 ${e.context}`});case"commit":if(c&&e.person&&!e.ok&&e.refused?.length){let a=S.approveRefused(e.refused);return(0,k.jsxs)(w,{flexDirection:"column",children:[_e(" \u2717 ",a.line,f??100).map((u,x)=>(0,k.jsx)(r,{color:o.red,children:u},`p-${x}`)),a.notes.flatMap((u,x)=>_e(" ",u,f??100).map((y,T)=>(0,k.jsx)(r,{color:o.dim,children:y},`n-${x}-${T}`)))]})}return(0,k.jsxs)(w,{flexDirection:"column",children:[c&&e.held?_e(" \u2016 ",e.line,f??100).map((a,u)=>(0,k.jsx)(r,{children:a},`h-${u}`)):f!==null?_e(` ${e.ok?"\u2714":"\u2717"} `,e.line,f).map((a,u)=>(0,k.jsx)(r,{color:e.ok?o.green:o.red,children:a},`c-${u}`)):(0,k.jsx)(r,{color:e.ok?o.green:o.red,children:` ${e.ok?"\u2714":"\u2717"} ${e.line}`}),c&&e.refused?.length?S.chatRefused(e.refused).flatMap((a,u)=>_e(" ",a,f??100).map((x,y)=>(0,k.jsx)(r,{color:o.dim,children:x},`r-${u}-${y}`))):(e.warnings??[]).flatMap((a,u)=>!c&&f!==null&&(e.era??0)>0?_e(" \u26A0 ",a,f).map((x,y)=>(0,k.jsx)(r,{color:o.dim,children:x},`w-${u}-${y}`)):[(0,k.jsx)(r,{color:o.dim,children:` \u26A0 ${a}`},`w-${u}`)])]});case"error":return(0,k.jsxs)(ur,{variant:"error",paddingX:1,children:[(0,k.jsx)(r,{color:o.red,children:e.title}),e.detail.map((a,u)=>(0,k.jsx)(r,{color:o.dim,children:a},`d-${u}`))]})}}var Oe=U(Y(),1);function Mr({item:e}){return(0,Oe.jsxs)(w,{flexDirection:"column",marginLeft:2,children:[(e.cite??[]).map((s,c)=>(0,Oe.jsx)(r,{dimColor:!0,children:`cite ${s.anchor??"conv"} \u2014 "${s.quote??""}"`},`cite-${c}`)),(e.depends_on_hint??[]).length>0&&(0,Oe.jsx)(r,{dimColor:!0,children:`depends on: ${(e.depends_on_hint??[]).join(", ")}`}),Object.entries(e.extra??{}).map(([s,c])=>(0,Oe.jsx)(r,{dimColor:!0,children:`${s}: ${c}`},`extra-${s}`))]})}var E=U(Y(),1),kn=(e,s)=>Math.max(0,Math.min(s,e));function Lt(e,s,c){switch(s.type){case"move":return e.level==="detail"?{...e,scroll:Math.max(0,(e.scroll??0)+s.delta)}:{...e,cursor:kn(e.cursor+s.delta,Math.max(0,c-1))};case"enter":return e.level==="list"?{...e,level:"detail",scroll:0}:e;case"back":return e.level==="detail"?{...e,level:"list",scroll:0}:null}}var Or={"use-case":"use-cases",ac:"acs",scenario:"scenarios",test:"tests",gap:"gaps"};function Pr(e,s){if(e.level==="detail")return{level:"detail",cursor:kn(e.num-1,Math.max(0,s.entries.length-1))};if(e.section){let c=s.entries.findIndex(f=>Or[f.kind]===e.section);if(c>=0)return{level:"list",cursor:c}}return{level:"list",cursor:0}}function rs(e){let s=[];for(let c of e.entries){let f=s.find(p=>p.kind===c.kind);f?f.entries.push(c):s.push({kind:c.kind,entries:[c]})}return s}var _r=3;function is({items:e,cursor:s,verb:c,more:f}){let p=`view \xB7 ${c} so far \xB7 ${e.counts.map(u=>`${u.count} ${u.count===1?u.label.replace(/s$/,""):u.label}`).join(" \xB7 ")}`,a=e.entries[s];return(0,E.jsxs)(w,{flexDirection:"column",children:[(0,E.jsx)(r,{bold:!0,color:o.assuranceAccent,children:p}),rs(e).map(({kind:u,entries:x})=>{let y=a?.kind===u,T=y?x.findIndex(C=>C.num===a.num):-1,P=y?kn(T-1,Math.max(0,x.length-_r)):0,V=x.slice(P,P+(y?_r:1)),re=x.length-V.length;return(0,E.jsxs)(w,{flexDirection:"column",children:[(0,E.jsx)(r,{color:o.dim,children:`${Or[u]??Ct(u)} \xB7 ${x.length}`}),V.map(C=>{let b=y&&C.num===a.num,I=C.item.badge;return(0,E.jsxs)(r,{children:[(0,E.jsx)(r,{color:o.assuranceAccent,children:b?"\u203A ":" "}),(0,E.jsx)(r,{children:`${C.num} \xB7 ${C.item.title}`}),I?(0,E.jsx)(r,{color:o.dim,children:` \xB7 ${I}`}):null]},`${C.kind}:${C.num}`)}),re>0&&(0,E.jsx)(r,{color:o.dim,children:` \u22EE ${re} more`})]},u)}),f?(0,E.jsxs)(r,{children:[(0,E.jsx)(r,{color:o.assuranceAccent,children:s===e.entries.length?"\u203A ":" "}),(0,E.jsx)(r,{color:o.dim,children:`\u22EF show all \u2014 ${f.hidden} more from earlier turns`})]}):null]})}var Bt=14;function ss({items:e,cursor:s,explain:c,grandTotal:f,dossier:p,scroll:a=0}){let u=e.entries[s];if(!u)return(0,E.jsx)(r,{color:o.dim,children:"nothing to show"});if(p){let y=Math.max(0,Math.min(a,Math.max(0,p.lines.length-Bt))),T=p.lines.slice(y,y+Bt);return(0,E.jsxs)(w,{flexDirection:"column",children:[(0,E.jsxs)(r,{bold:!0,children:[`view \xB7 ${p.id}`,p.id.toLowerCase()!==p.rawId?(0,E.jsx)(r,{bold:!1,color:o.dim,children:` \xB7 ${p.rawId}`}):null]}),(0,E.jsx)(r,{bold:!0,children:p.title}),y>0?(0,E.jsx)(r,{color:o.muted,children:`\u22EE ${y} above`}):null,T.map((P,V)=>(0,E.jsx)(r,{color:P.dim?o.dim:void 0,children:P.text},`dl-${V}`)),p.lines.length>y+Bt?(0,E.jsx)(r,{color:o.muted,children:`\u22EE ${p.lines.length-y-Bt} more`}):null]})}let x=u.item;return(0,E.jsxs)(w,{flexDirection:"column",children:[(0,E.jsx)(r,{bold:!0,children:`view \xB7 ${u.kind} ${u.num} of ${f??e.entries.length}`}),(0,E.jsx)(r,{children:u.item.title}),x.badge?(0,E.jsx)(r,{color:o.dim,children:`kind: ${x.badge}`}):null,x.why?(0,E.jsx)(r,{color:o.dim,children:x.why}):null,(0,E.jsx)(Mr,{item:u.item}),c?.map((y,T)=>(0,E.jsx)(r,{color:o.dim,children:y},`ex-${T}`)),(0,E.jsx)(r,{color:o.dim,children:"view-only \u2014 approvals happen in chat"})]})}function jr({items:e,state:s,verb:c,more:f,explain:p,grandTotal:a,dossier:u=null}){return s.level==="list"?(0,E.jsx)(is,{items:e,cursor:s.cursor,verb:c,more:f}):(0,E.jsx)(ss,{items:e,cursor:s.cursor,explain:p,grandTotal:a,dossier:u,scroll:s.scroll??0})}var J=U(Y(),1),vn=14;function os(e){let s=[],c=null;for(let f of e)f.field!==c&&(c=f.field,s.push({kind:"field",field:c})),s.push({kind:"line",field:c,line:f});return s}function Fr({title:e,lines:s,offset:c=0,remote:f=!1}){let p=os(s),a=Math.max(0,Math.min(c,Math.max(0,p.length-vn))),u=p.slice(a,a+vn),x=a,y=Math.max(0,p.length-a-vn),T=f?`the change to ${e} \xB7 old \u2192 new`:`view \xB7 diff \xB7 ${e} \xB7 current \u2192 proposed`;return(0,J.jsxs)(w,{flexDirection:"column",children:[(0,J.jsx)(r,{bold:!0,color:o.assuranceAccent,children:T}),x>0?(0,J.jsx)(w,{paddingLeft:2,children:(0,J.jsx)(r,{color:o.dim,children:`\u22EE ${x} above`})}):null,u.map((P,V)=>P.kind==="field"?(0,J.jsx)(w,{paddingLeft:2,children:(0,J.jsx)(r,{color:o.dim,children:P.field==="criteria"?f?"acceptance criteria":"criteria":P.field})},`r-${a+V}`):(0,J.jsx)(w,{paddingLeft:4,children:(0,J.jsx)(r,{color:P.line.op==="-"?"red":"green",children:`${P.line.op==="-"?"\u2212":"+"} ${P.line.text}`})},`r-${a+V}`)),y>0?(0,J.jsx)(w,{paddingLeft:2,children:(0,J.jsx)(r,{color:o.dim,children:`\u22EE ${y} more`})}):null]})}var ls={"use-cases":"use-cases",usecases:"use-cases","use-case":"use-cases",acs:"acs",ac:"acs",scenarios:"scenarios",scenario:"scenarios",tests:"tests",test:"tests",gaps:"gaps",gap:"gaps"};function qr(e){let s=(e??"").trim().toLowerCase();if(!s)return{level:"list"};if(/^\d+$/.test(s)){let f=parseInt(s,10);return f>=1?{level:"detail",num:f}:{error:"items are numbered from 1 \u2014 /view 1"}}let c=ls[s];return c?{level:"list",section:c}:{error:"try /view, /view <number>, or /view acs|scenarios|tests"}}var D=U(Y(),1),as=6,Nr=12;function cs(e,s,c){let f=Math.max(20,s),p=[];for(let u of e.split(`
2
+ import{b as Tr}from"./chunk-6QH75BPJ.js";import{a as dn,c as mn,e as Et,f as Je,g as $r,h as Rr,i as gn,j as Cr}from"./chunk-XKOVEMVZ.js";import{a as St,b as un}from"./chunk-JTNEF5ZP.js";import{a as ln,b as wr}from"./chunk-EJGCIGQY.js";import{a as xr,b as kr,c as vr}from"./chunk-YWWVF5OU.js";import{a as pr,b as ue}from"./chunk-YILRYMMG.js";import{a as dr}from"./chunk-5Y2G4NC7.js";import{c as Rt}from"./chunk-SMXABALN.js";import{b as fr}from"./chunk-WN5VKKJ3.js";import{b as fn}from"./chunk-HD6NR44L.js";import{a as Ct,b as an,c as Ye,d as yr,e as cn}from"./chunk-BWXLZS5O.js";import{e as ze,f as S,g as br}from"./chunk-LRNUGKYH.js";import{b as gr,c as Ge,d as hr}from"./chunk-22PIMG52.js";import{na as mr,oa as on}from"./chunk-PI7OXS62.js";import{a as ur}from"./chunk-ND6OP3O2.js";import{a as Y}from"./chunk-HCBYKLMW.js";import{a as w,b as r,k as Me}from"./chunk-33DWJV67.js";import{a as cr}from"./chunk-6YGTRKDT.js";import{z as o}from"./chunk-J4FIESTB.js";import{e as U}from"./chunk-UR6MHSHU.js";var bn=U(cr(),1);var g=U(cr(),1);var m=U(Y(),1),Wi=60,Vi=100;function hn(e,s){let c=e.options.length,f=c,p=e.multi_select?f++:null,a=e.allow_free_text?f++:null,u=s?f++:null;return{optionCount:c,doneIdx:p,freeIdx:a,batchIdx:u,maxSel:f-1}}var Ki="\xA0",Ui={high:{text:`\u203C${Ki}high`,color:o.red},med:{text:"med",color:"yellow"},low:{text:"low",color:o.dim}};function Hi(e){let s=(e.header??e.text.split(/\s+/).slice(0,3).join(" ")).trim();return s.length>16?`${s.slice(0,15)}\u2026`:s}function Qi(e,s,c){let f=x=>e[x].length+6,p=f(s),a=s,u=s;for(;;){let x=u+1<e.length?f(u+1):1/0,y=a-1>=0?f(a-1):1/0;if(x===1/0&&y===1/0)break;if(x<=y){if(p+x>c)break;p+=x,u+=1}else{if(p+y>c)break;p+=y,a-=1}}return{lo:a,hi:u}}function Sr({batch:e,qView:s,sel:c=0,focused:f=!1,freeText:p=null,optionText:a=null,attach:u=null,multiSelFor:x,childPrefix:y,gapAbove:T=!0}){let{stdout:P}=Me(),V=P?.columns??80,re=V<Wi,C=Math.min(V-1,Vi),b=Math.max(0,Math.min(e.questions.length-1,s??(e.cursor<0?0:e.cursor))),I=e.questions[b],pe=e.resolution[b],q=e.resolution.filter(B=>!B).length,fe=e.questions.length-q,we=St(e),W=hn(I,we!==""),xe=x?x(b):[],ie=Ui[I.risk],Z=B=>f&&c===B?(0,m.jsx)(r,{color:o.assuranceAccent,children:"\u276F"}):" ",A=`? ${y??""}the agent needs ${q===1?"one answer":`${q} answers`}`,Pe=e.questions.length>1?` \xB7 ${b+1} of ${e.questions.length} \xB7 ${fe} answered`:"",H=(0,m.jsxs)(w,{flexDirection:"column",children:[(0,m.jsx)(w,{paddingLeft:2,children:(0,m.jsxs)(r,{bold:!0,children:[I.text,ie?(0,m.jsx)(r,{color:ie.color,bold:!1,children:` ${ie.text}`}):null]})}),(0,m.jsx)(w,{paddingLeft:2,children:(0,m.jsx)(r,{color:o.dim,children:I.rationale})}),(0,m.jsx)(r,{children:" "}),I.options.map((B,$)=>{let Q=f&&c===$;return a&&a.optionIndex===$?(0,m.jsx)(w,{flexDirection:"column",children:(0,m.jsxs)(w,{children:[(0,m.jsxs)(r,{children:[(0,m.jsx)(r,{color:o.assuranceAccent,children:"\u276F"})," ",(0,m.jsx)(r,{color:o.assuranceAccent,children:`${$+1}. ${un(B.label)}`}),(0,m.jsx)(r,{color:o.dim,children:" \u270E "})]}),(0,m.jsx)(Rt,{value:a.value,onChange:a.onChange,onSubmit:a.onSubmit,onCancel:a.onCancel,placeholder:B.detail||"type your answer"})]})},`o-${$}`):(0,m.jsxs)(w,{flexDirection:"column",children:[(0,m.jsxs)(r,{children:[Z($)," ",I.multi_select?(0,m.jsx)(r,{color:xe.includes($)?o.green:o.dim,children:xe.includes($)?"[x] ":"[ ] "}):null,(0,m.jsx)(r,{color:Q?o.assuranceAccent:void 0,children:`${$+1}. ${un(B.label)}`}),$===I.recommended_index?(0,m.jsx)(r,{color:o.dim,children:" (recommended)"}):null,pe?.selected_index===$?(0,m.jsx)(r,{color:o.dim,children:" (current)"}):null]}),B.detail?(0,m.jsx)(w,{paddingLeft:5,children:(0,m.jsx)(r,{color:o.dim,children:B.detail})}):null]},`o-${$}`)}),I.multi_select&&W.doneIdx!=null?(0,m.jsxs)(r,{children:[Z(W.doneIdx)," ",(0,m.jsx)(r,{color:o.green,children:"\u2714"}),(0,m.jsx)(r,{color:f&&c===W.doneIdx?o.assuranceAccent:void 0,children:" done \u2014 confirm selection"})]}):null,I.allow_free_text?(0,m.jsx)(r,{children:" "}):null,I.allow_free_text?p?(0,m.jsxs)(w,{children:[(0,m.jsxs)(r,{children:[(0,m.jsx)(r,{color:o.assuranceAccent,children:"\u276F"})," ",(0,m.jsx)(r,{color:o.dim,children:"\u270E "})]}),(0,m.jsx)(Rt,{value:p.value,onChange:p.onChange,onSubmit:p.onSubmit,onCancel:p.onCancel,placeholder:"Tell me what to do"})]}):(0,m.jsxs)(r,{children:[W.freeIdx!=null?Z(W.freeIdx):" "," ",(0,m.jsx)(r,{color:f&&W.freeIdx!=null&&c===W.freeIdx?o.assuranceAccent:o.dim,children:"\u270E Tell me what to do"})]}):null,u?(0,m.jsxs)(w,{flexDirection:"column",marginTop:1,children:[(0,m.jsxs)(w,{children:[(0,m.jsxs)(r,{children:[(0,m.jsx)(r,{color:o.assuranceAccent,children:"\u276F"})," ",(0,m.jsx)(r,{color:o.assuranceAccent,children:"@ attach a file or URL"}),(0,m.jsx)(r,{color:o.dim,children:" \u270E "})]}),(0,m.jsx)(Rt,{value:u.value,onChange:u.onChange,onSubmit:u.onSubmit,onCancel:u.onCancel,placeholder:"path or URL"})]}),(0,m.jsx)(w,{paddingLeft:2,children:(0,m.jsx)(r,{color:o.dim,children:"the questions are set aside \u2014 the agent reads the source and re-asks what's still open"})})]}):null]}),F=we!==""?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(r,{children:" "}),(0,m.jsxs)(r,{children:[f&&W.batchIdx!=null&&c===W.batchIdx?(0,m.jsx)(r,{color:o.assuranceAccent,children:"\u276F"}):" "," ",(0,m.jsx)(r,{color:o.assuranceAccent,children:"\xBB"}),(0,m.jsx)(r,{bold:!0,color:f&&W.batchIdx!=null&&c===W.batchIdx?o.assuranceAccent:void 0,children:" Go with recommendations"}),q>=5?(0,m.jsx)(r,{color:o.dim,children:` \u2014 resolves all ${q} open`}):null,(0,m.jsx)(r,{color:o.dim,children:" (tab)"})]})]}):null;if(re)return(0,m.jsxs)(w,{marginTop:T?1:0,marginBottom:1,flexDirection:"column",children:[(0,m.jsx)(r,{color:o.assuranceAccent,bold:!0,children:A}),e.questions.length>1?(0,m.jsx)(r,{color:o.dim,children:Pe.replace(/^ · /,"")}):null,(0,m.jsx)(r,{children:" "}),H,F]});let h=e.questions.map(B=>Hi(B)),me=e.questions.length>1?Qi(h,b,C-8):null;return(0,m.jsxs)(w,{marginTop:T?1:0,marginBottom:1,flexDirection:"column",children:[(0,m.jsxs)(r,{color:o.assuranceAccent,children:[(0,m.jsx)(r,{bold:!0,children:A}),Pe?(0,m.jsx)(r,{color:o.dim,children:Pe}):null]}),me?(0,m.jsx)(w,{marginTop:1,children:(0,m.jsxs)(r,{children:[me.lo>0?(0,m.jsx)(r,{color:o.dim,children:"\u25C0 "}):" ",e.questions.slice(me.lo,me.hi+1).map((B,$)=>{let Q=me.lo+$,et=$>0?" ":"";return Q===b?(0,m.jsxs)(r,{children:[et,(0,m.jsx)(r,{backgroundColor:o.assuranceAccent,color:"#0d1117",bold:!0,children:` ${h[Q]} `})]},B.id):(0,m.jsxs)(r,{children:[et,e.resolution[Q]?(0,m.jsxs)(r,{children:[(0,m.jsx)(r,{color:o.green,children:"\u2713 "}),(0,m.jsx)(r,{color:o.dim,children:h[Q]})]}):(0,m.jsx)(r,{color:o.dim,children:`\u25CB ${h[Q]}`})]},B.id)}),me.hi<e.questions.length-1?(0,m.jsx)(r,{color:o.dim,children:" \u25B6"}):null]})}):null,(0,m.jsx)(r,{children:" "}),H,F]})}var Er={ac:["acceptance criterion","acceptance criteria"],gap:["open question","open questions"],scenario:["scenario","scenarios"],test:["test","tests"],"use-case":["use-case","use-cases"]},pn=e=>Er[e]?.[1]??`${e}s`,At={label:(e,s)=>s===1?Er[e]?.[0]??e:pn(e),skip:new Set(["exercise"])},xn={ac:null,test:null,gap:null,scenario:"kind"},Xi=(e,s,c)=>`${e} ${e===1?s:c}`,Gi=e=>e.length<2?e.join(""):`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`;function Ar(e){let s=e.covers?on(e.covers):"1 scenario",c=e.verifies.slice(0,2).map(on),f=e.verifiesTotal-c.length,p=c.length===0?Xi(e.verifiesTotal,"acceptance criterion","acceptance criteria"):Gi([...c,...f>0?[`${f} more`]:[]]);return`covers ${s} \xB7 verifies ${p}`}function Dr(e,s){let c=typeof s=="string"&&s!==""?s.split(", "):[],f=p=>typeof p=="string"&&mr.test(p);return{covers:f(e)?e:null,verifies:c.filter(f),verifiesTotal:c.length}}var Dt={"acceptance criteria":{name:"acceptance criteria",next:"scenarios",done:"acceptance criteria say what the use-case must always do"},scenarios:{name:"scenarios",next:"scenario checks",done:"scenarios are the paths a user takes that test the criteria"},"acceptance criteria + exercises":{name:"scenario checks",next:"tests",done:"scenario checks say which criteria each scenario checks"},"tests + gaps":{name:"tests"},tests:{name:"tests"}};function Ze(e){let s=Dt[e]?.name;if(s)return s;let c={exercises:"scenario checks",gaps:"open questions"};return[...new Set(e.split(" + ").map(f=>c[f]??f))].join(" + ")}var Ir={scenarios:"next, scenarios: the paths a user takes that test them","scenario checks":"next, scenario checks: which criteria each scenario checks",tests:"next, tests: runnable tests, and open questions for what can't run"},Br="phases: acceptance criteria \u2192 scenarios \u2192 scenario checks \u2192 tests";var k=U(Y(),1),zi=e=>e.startsWith("designing: ")?`designing: ${Ze(e.slice(11))}`:e;function Yi(e,s){let c=e.form==="assumed"?" (assumed)":e.form==="deferred"?"":" (you)",f=e.note?` \u2014 ${e.note}`:"",p=s?`"${e.stub}"`:`q${e.qNum} ${e.stub}`;return e.form==="deferred"?`\u21B3 deferred ${p}${f}`:e.form==="changed"?`\u21B3 changed ${p}: ${e.prev??"?"} \u2192 ${e.choice??"?"}${c}${f}`:`\u21B3 ${e.form} ${p}: ${e.choice??"?"}${c}${f}`}var Ji=()=>(process.stdout?.columns??100)-12,Zi=new Set(["banner","header","user","agent","worked","childOpen","lines"]);function Lr({block:e,annotations:s,remote:c=!1,afterHeader:f=!1}){let p=e.era??0,{stdout:a}=Me(),u=c||p>0?(a?.columns??100)-p*2:null,x=ns(e,s??null,c,u,(a?.columns??100)-p*2),y=p>0?(0,k.jsx)(w,{marginLeft:p*2,children:x}):x;return f&&!Zi.has(e.kind)?(0,k.jsx)(w,{marginTop:1,children:y}):y}var es=new RegExp("[\\u1100-\\u115F\\u2E80-\\u303E\\u3041-\\uA4CF\\uAC00-\\uD7A3\\uF900-\\uFAFF\\uFE10-\\uFE19\\uFE30-\\uFE6F\\uFF00-\\uFF60\\uFFE0-\\uFFE6\\u{20000}-\\u{3FFFD}\u2714\u26A0]|\\p{Emoji_Presentation}","u"),It=e=>[...e].reduce((s,c)=>s+(es.test(c)?2:1),0);function ts(e,s,c){let f=Math.max(12,c-It(e)),p=[],a="";for(let u of s){let x=a?`${a} \xB7 ${u}`:u;It(x)>f&&a?(p.push(a),a=u):a=x}return p.push(a),p.map((u,x)=>(x===0?e:" ".repeat(e.length))+u)}function _e(e,s,c){let f=Math.max(12,c-It(e)),p=[],a="";for(let u of s.split(" ")){let x=a?`${a} ${u}`:u;It(x)>f&&a?(p.push(a),a=u):a=x}return p.push(a),p.map((u,x)=>(x===0?e:" ".repeat(e.length))+u)}function ns(e,s,c,f=null,p=100){switch(e.kind){case"banner":return(0,k.jsx)(w,{marginTop:1,children:(0,k.jsx)(r,{bold:!0,color:o.assuranceAccent,children:` ${c?zi(e.text):e.text}`})});case"header":return(0,k.jsx)(w,{marginTop:1,children:(0,k.jsxs)(r,{color:o.assuranceAccent,children:[`\u25CF ${e.text}`,e.tail?(0,k.jsx)(r,{color:o.dim,children:` \u2014 ${e.tail}`}):null]})});case"user":return(0,k.jsxs)(w,{marginTop:1,children:[(0,k.jsx)(r,{color:o.orange,children:"\u276F "}),(0,k.jsx)(r,{children:e.text})]});case"note":return(0,k.jsx)(r,{color:o.dim,children:` ${e.text}`});case"lines":return(0,k.jsx)(w,{flexDirection:"column",marginTop:1,children:e.lines.map((a,u)=>(0,k.jsx)(r,{...a.dim?{color:o.dim}:{},children:a.text},u))});case"agent":return(0,k.jsx)(w,{marginTop:1,children:(0,k.jsx)(kr,{text:e.text,accent:o.assuranceAccent,indent:f===null?0:(e.era??0)*2})});case"worked":return(0,k.jsx)(w,{marginTop:1,flexDirection:"column",children:ts(" \u2699 ",hr(e.durS,e.toolCalls,e.tools),p).map((a,u)=>(0,k.jsx)(r,{color:o.dim,children:a},u))});case"usage":return(0,k.jsx)(r,{color:o.dim,children:` \xB7 ${e.credits.toFixed(1)} credits \u2014 total ${e.total.toFixed(1)}`});case"turn":{let a=s,u=(a?a.fresh:e.items.map((C,b)=>({item:C,num:b+1,updated:!1}))).filter(C=>!(c&&At.skip?.has(C.item.kind??""))),x={usecase:"risk","use-case":"risk",ac:"check",scenario:"kind",test:"check",gap:"risk",stylenote:"kind"},y=C=>C.kind??"use-case",T=new Map;for(let C of u){let b=C.item,I=y(C.item),pe=c&&I==="test"?{title:b.title,summary:Ar(b.links??Dr(b.extra?.automates,b.extra?.verifies)),badge:""}:c&&I==="gap"?{title:b.question??"",summary:b.rationale??"",badge:""}:null,q=b.risk==="high"||b.risk==="med"||b.risk==="low"?b.risk:void 0,fe=b.logical_id??(c?b.matched_id:void 0),we={id:fe??"",staged:!fe,...c&&b.held&&!fe?{held:!0}:{},title:pe?.title??b.title,badge:pe?.badge??b.badge??b.risk??"",summary:pe?.summary??b.why??b.summary??b.description??"",...q?{risk:q}:{},...C.updated?{marker:"\u21B3 changed"}:{}},W=T.get(I)??[];W.push(we),T.set(I,W)}let P=u.some(C=>!!C.item.kind),V=(a?.unchanged??[]).reduce((C,b)=>C+b.count,0),re=a?.headerStats?` \u2014 ${a.headerStats}${V>0?` (${V} unchanged)`:""}`:"";return(0,k.jsxs)(w,{flexDirection:"column",marginLeft:2,children:[(0,k.jsxs)(r,{bold:!0,children:[P?"design":e.heading,re?(0,k.jsx)(r,{bold:!1,color:o.dim,children:re}):null]}),[...T.entries()].map(([C,b])=>(0,k.jsxs)(w,{flexDirection:"column",children:[T.size>1?(0,k.jsx)(r,{color:o.dim,children:`${c?pn(C):Ct(C)} \xB7 ${b.length}`}):null,(0,k.jsx)(Tr,{rows:b,width:Ji(),badgeHeader:c&&C in xn?xn[C]:x[C]??"info"})]},C)),a&&a.unchanged.length>0&&(0,k.jsx)(r,{color:o.dim,children:` \u22EE unchanged: ${a.unchanged.map(C=>`${C.count} ${C.label}`).join(" \xB7 ")}`})]})}case"answer":return(0,k.jsx)(r,{color:o.dim,children:Yi(e.receipt,c)});case"continued":return(0,k.jsx)(r,{color:o.dim,children:"\u21B3 continued"});case"childOpen":{if(c)return(0,k.jsx)(w,{marginTop:1,children:(0,k.jsx)(r,{color:o.assuranceAccent,children:`\u25CF ${e.update?S.updateOpen(e.subject,e.changed===!0):S.childOpen(e.verb,e.subject)}`})});let{ing:a}=fn(e.verb);return(0,k.jsx)(w,{marginTop:1,children:(0,k.jsxs)(r,{color:o.assuranceAccent,children:[`\u25CF ${a} ${e.subject}`,e.sid?(0,k.jsx)(r,{color:o.dim,children:` \u2014 ${e.sid}`}):null,e.note?(0,k.jsx)(r,{color:o.dim,children:` ${e.note}`}):null]})})}case"childClose":{if(e.held)return(0,k.jsx)(w,{});if(c&&e.update){let x=[Ge(e.durS),...e.credits!==void 0?[`${e.credits.toFixed(1)} credits`]:[]];if(!e.ok)return(0,k.jsx)(r,{color:o.red,children:`\u25CF ${S.updateFailed(e.subject)}`});if(e.untouched)return(0,k.jsx)(r,{children:`\u25CF ${S.updateUntouched(e.subject)} \u2014 ${x.join(" \xB7 ")}`});if(e.unfinished)return(0,k.jsx)(r,{children:`\u25CF ${S.updateUnfinished(e.subject)} \u2014 ${x.join(" \xB7 ")}`});let y=e.testsWritten?S.updateTests(e.testsWritten):null,T=[x[0],...y?[y]:[],...x.slice(1)];return(0,k.jsx)(r,{color:o.green,children:`\u25CF ${S.updateClosed(e.subject,T)}`})}if(c){if(!e.ok)return(0,k.jsx)(r,{color:o.red,children:`\u25CF ${S.childFailed(e.verb,e.subject)}`});if(e.unfinished)return(0,k.jsx)(r,{children:`\u25CF ${[S.childUnfinished(e.verb),[Ge(e.durS),...e.credits!==void 0?[`${e.credits.toFixed(1)} credits`]:[]].join(" \xB7 ")].join(" \u2014 ")}`});let x=[Ge(e.durS),...e.tests?[S.childTests(e.verb,e.tests)]:[],...e.credits!==void 0?[`${e.credits.toFixed(1)} credits`]:[]];return(0,k.jsx)(r,{color:o.green,children:`\u25CF ${S.childClosed(e.verb,e.subject,x)}`})}let{ed:a}=fn(e.verb);if(!e.ok)return(0,k.jsxs)(r,{color:o.red,children:[`\u25CF ${e.verb} failed \u2014 ${e.exitCode!=null?`exited ${e.exitCode}`:"error"}`,e.fixCmd?(0,k.jsx)(r,{color:o.dim,children:` \xB7 ${e.fixCmd}`}):null]});let u=[Ge(e.durS),...e.results?[e.results]:[],...e.credits!==void 0?[`${e.credits.toFixed(1)} credits`]:[]].join(" \xB7 ");return(0,k.jsx)(r,{color:o.green,children:`\u25CF ${a} ${e.subject} \u2014 ${u}`})}case"childBack":return(0,k.jsx)(r,{color:o.dim,children:`back with ${e.parentVerb} \u2014 ${e.context}`});case"commit":if(c&&e.person&&!e.ok&&e.refused?.length){let a=S.approveRefused(e.refused);return(0,k.jsxs)(w,{flexDirection:"column",children:[_e(" \u2717 ",a.line,f??100).map((u,x)=>(0,k.jsx)(r,{color:o.red,children:u},`p-${x}`)),a.notes.flatMap((u,x)=>_e(" ",u,f??100).map((y,T)=>(0,k.jsx)(r,{color:o.dim,children:y},`n-${x}-${T}`)))]})}return(0,k.jsxs)(w,{flexDirection:"column",children:[c&&e.held?_e(" \u2016 ",e.line,f??100).map((a,u)=>(0,k.jsx)(r,{children:a},`h-${u}`)):f!==null?_e(` ${e.ok?"\u2714":"\u2717"} `,e.line,f).map((a,u)=>(0,k.jsx)(r,{color:e.ok?o.green:o.red,children:a},`c-${u}`)):(0,k.jsx)(r,{color:e.ok?o.green:o.red,children:` ${e.ok?"\u2714":"\u2717"} ${e.line}`}),c&&e.refused?.length?S.chatRefused(e.refused).flatMap((a,u)=>_e(" ",a,f??100).map((x,y)=>(0,k.jsx)(r,{color:o.dim,children:x},`r-${u}-${y}`))):(e.warnings??[]).flatMap((a,u)=>!c&&f!==null&&(e.era??0)>0?_e(" \u26A0 ",a,f).map((x,y)=>(0,k.jsx)(r,{color:o.dim,children:x},`w-${u}-${y}`)):[(0,k.jsx)(r,{color:o.dim,children:` \u26A0 ${a}`},`w-${u}`)])]});case"error":return(0,k.jsxs)(ur,{variant:"error",paddingX:1,children:[(0,k.jsx)(r,{color:o.red,children:e.title}),e.detail.map((a,u)=>(0,k.jsx)(r,{color:o.dim,children:a},`d-${u}`))]})}}var Oe=U(Y(),1);function Mr({item:e}){return(0,Oe.jsxs)(w,{flexDirection:"column",marginLeft:2,children:[(e.cite??[]).map((s,c)=>(0,Oe.jsx)(r,{dimColor:!0,children:`cite ${s.anchor??"conv"} \u2014 "${s.quote??""}"`},`cite-${c}`)),(e.depends_on_hint??[]).length>0&&(0,Oe.jsx)(r,{dimColor:!0,children:`depends on: ${(e.depends_on_hint??[]).join(", ")}`}),Object.entries(e.extra??{}).map(([s,c])=>(0,Oe.jsx)(r,{dimColor:!0,children:`${s}: ${c}`},`extra-${s}`))]})}var E=U(Y(),1),kn=(e,s)=>Math.max(0,Math.min(s,e));function Lt(e,s,c){switch(s.type){case"move":return e.level==="detail"?{...e,scroll:Math.max(0,(e.scroll??0)+s.delta)}:{...e,cursor:kn(e.cursor+s.delta,Math.max(0,c-1))};case"enter":return e.level==="list"?{...e,level:"detail",scroll:0}:e;case"back":return e.level==="detail"?{...e,level:"list",scroll:0}:null}}var Or={"use-case":"use-cases",ac:"acs",scenario:"scenarios",test:"tests",gap:"gaps"};function Pr(e,s){if(e.level==="detail")return{level:"detail",cursor:kn(e.num-1,Math.max(0,s.entries.length-1))};if(e.section){let c=s.entries.findIndex(f=>Or[f.kind]===e.section);if(c>=0)return{level:"list",cursor:c}}return{level:"list",cursor:0}}function rs(e){let s=[];for(let c of e.entries){let f=s.find(p=>p.kind===c.kind);f?f.entries.push(c):s.push({kind:c.kind,entries:[c]})}return s}var _r=3;function is({items:e,cursor:s,verb:c,more:f}){let p=`view \xB7 ${c} so far \xB7 ${e.counts.map(u=>`${u.count} ${u.count===1?u.label.replace(/s$/,""):u.label}`).join(" \xB7 ")}`,a=e.entries[s];return(0,E.jsxs)(w,{flexDirection:"column",children:[(0,E.jsx)(r,{bold:!0,color:o.assuranceAccent,children:p}),rs(e).map(({kind:u,entries:x})=>{let y=a?.kind===u,T=y?x.findIndex(C=>C.num===a.num):-1,P=y?kn(T-1,Math.max(0,x.length-_r)):0,V=x.slice(P,P+(y?_r:1)),re=x.length-V.length;return(0,E.jsxs)(w,{flexDirection:"column",children:[(0,E.jsx)(r,{color:o.dim,children:`${Or[u]??Ct(u)} \xB7 ${x.length}`}),V.map(C=>{let b=y&&C.num===a.num,I=C.item.badge;return(0,E.jsxs)(r,{children:[(0,E.jsx)(r,{color:o.assuranceAccent,children:b?"\u203A ":" "}),(0,E.jsx)(r,{children:`${C.num} \xB7 ${C.item.title}`}),I?(0,E.jsx)(r,{color:o.dim,children:` \xB7 ${I}`}):null]},`${C.kind}:${C.num}`)}),re>0&&(0,E.jsx)(r,{color:o.dim,children:` \u22EE ${re} more`})]},u)}),f?(0,E.jsxs)(r,{children:[(0,E.jsx)(r,{color:o.assuranceAccent,children:s===e.entries.length?"\u203A ":" "}),(0,E.jsx)(r,{color:o.dim,children:`\u22EF show all \u2014 ${f.hidden} more from earlier turns`})]}):null]})}var Bt=14;function ss({items:e,cursor:s,explain:c,grandTotal:f,dossier:p,scroll:a=0}){let u=e.entries[s];if(!u)return(0,E.jsx)(r,{color:o.dim,children:"nothing to show"});if(p){let y=Math.max(0,Math.min(a,Math.max(0,p.lines.length-Bt))),T=p.lines.slice(y,y+Bt);return(0,E.jsxs)(w,{flexDirection:"column",children:[(0,E.jsxs)(r,{bold:!0,children:[`view \xB7 ${p.id}`,p.id.toLowerCase()!==p.rawId?(0,E.jsx)(r,{bold:!1,color:o.dim,children:` \xB7 ${p.rawId}`}):null]}),(0,E.jsx)(r,{bold:!0,children:p.title}),y>0?(0,E.jsx)(r,{color:o.muted,children:`\u22EE ${y} above`}):null,T.map((P,V)=>(0,E.jsx)(r,{color:P.dim?o.dim:void 0,children:P.text},`dl-${V}`)),p.lines.length>y+Bt?(0,E.jsx)(r,{color:o.muted,children:`\u22EE ${p.lines.length-y-Bt} more`}):null]})}let x=u.item;return(0,E.jsxs)(w,{flexDirection:"column",children:[(0,E.jsx)(r,{bold:!0,children:`view \xB7 ${u.kind} ${u.num} of ${f??e.entries.length}`}),(0,E.jsx)(r,{children:u.item.title}),x.badge?(0,E.jsx)(r,{color:o.dim,children:`kind: ${x.badge}`}):null,x.why?(0,E.jsx)(r,{color:o.dim,children:x.why}):null,(0,E.jsx)(Mr,{item:u.item}),c?.map((y,T)=>(0,E.jsx)(r,{color:o.dim,children:y},`ex-${T}`)),(0,E.jsx)(r,{color:o.dim,children:"view-only \u2014 approvals happen in chat"})]})}function jr({items:e,state:s,verb:c,more:f,explain:p,grandTotal:a,dossier:u=null}){return s.level==="list"?(0,E.jsx)(is,{items:e,cursor:s.cursor,verb:c,more:f}):(0,E.jsx)(ss,{items:e,cursor:s.cursor,explain:p,grandTotal:a,dossier:u,scroll:s.scroll??0})}var J=U(Y(),1),vn=14;function os(e){let s=[],c=null;for(let f of e)f.field!==c&&(c=f.field,s.push({kind:"field",field:c})),s.push({kind:"line",field:c,line:f});return s}function Fr({title:e,lines:s,offset:c=0,remote:f=!1}){let p=os(s),a=Math.max(0,Math.min(c,Math.max(0,p.length-vn))),u=p.slice(a,a+vn),x=a,y=Math.max(0,p.length-a-vn),T=f?`the change to ${e} \xB7 old \u2192 new`:`view \xB7 diff \xB7 ${e} \xB7 current \u2192 proposed`;return(0,J.jsxs)(w,{flexDirection:"column",children:[(0,J.jsx)(r,{bold:!0,color:o.assuranceAccent,children:T}),x>0?(0,J.jsx)(w,{paddingLeft:2,children:(0,J.jsx)(r,{color:o.dim,children:`\u22EE ${x} above`})}):null,u.map((P,V)=>P.kind==="field"?(0,J.jsx)(w,{paddingLeft:2,children:(0,J.jsx)(r,{color:o.dim,children:P.field==="criteria"?f?"acceptance criteria":"criteria":P.field})},`r-${a+V}`):(0,J.jsx)(w,{paddingLeft:4,children:(0,J.jsx)(r,{color:P.line.op==="-"?"red":"green",children:`${P.line.op==="-"?"\u2212":"+"} ${P.line.text}`})},`r-${a+V}`)),y>0?(0,J.jsx)(w,{paddingLeft:2,children:(0,J.jsx)(r,{color:o.dim,children:`\u22EE ${y} more`})}):null]})}var ls={"use-cases":"use-cases",usecases:"use-cases","use-case":"use-cases",acs:"acs",ac:"acs",scenarios:"scenarios",scenario:"scenarios",tests:"tests",test:"tests",gaps:"gaps",gap:"gaps"};function qr(e){let s=(e??"").trim().toLowerCase();if(!s)return{level:"list"};if(/^\d+$/.test(s)){let f=parseInt(s,10);return f>=1?{level:"detail",num:f}:{error:"items are numbered from 1 \u2014 /view 1"}}let c=ls[s];return c?{level:"list",section:c}:{error:"try /view, /view <number>, or /view acs|scenarios|tests"}}var D=U(Y(),1),as=6,Nr=12;function cs(e,s,c){let f=Math.max(20,s),p=[];for(let u of e.split(`
3
3
  `)){if(u.length<=f){p.push(u);continue}let x="";for(let y of u.split(" "))x&&x.length+1+y.length>f?(p.push(x),x=y):x=x?`${x} ${y}`:y;p.push(x)}let a=Math.max(0,p.length-c);return{body:p.slice(-c).join(`
4
4
  `),hidden:a}}function wn(e){return e.resumed?[{role:"agent",turnIndex:0,items:e.resumed.items},...e.turns]:e.turns}function Wr(e){let s={key:"redesign",label:"re-design from scratch",detail:"replaces the current design"},c={key:"keep",label:"keep the existing design",detail:"back to the list"};return e.designed==="stale"?[{...s,detail:"the use-case changed since it was designed"},c]:[c,s]}function Vr(e){return e.length===0?null:{approved:e.filter(s=>s.verdict==="approve").length,rejected:e.filter(s=>s.verdict==="reject").length,deferred:e.filter(s=>s.verdict==="defer").length}}function ds(e,s){return s?`the changes in ${e} could not be read: ${s.message}`:"no reviewable changes came back \u2014 the source may be unchanged"}function fo({controller:e,verb:s="extract",onCtrlC:c,chain:f=null,inspect:p=null,reconcile:a=null,autoReview:u=!1,onReviewExit:x,meta:y=null,remote:T=null}){let[,P]=(0,g.useState)(0),[V,re]=(0,g.useState)(!1),[C,b]=(0,g.useState)(null),[I,pe]=(0,g.useState)(null),q=(0,g.useRef)(null),[fe,we]=(0,g.useState)(null),W=(0,g.useRef)(null),xe=t=>{W.current=t,we(t)},ie=t=>{q.current=t,pe(t),t===null&&xe(null)},Z=(0,g.useRef)([]),[A,Pe]=(0,g.useState)(null),H=(0,g.useRef)(null),F=t=>{H.current=t,Pe(t)},[h,me]=(0,g.useState)(null),B=(0,g.useRef)(null),$=t=>{B.current=t,me(t)},[Q,et]=(0,g.useState)(null),yn=(0,g.useRef)(null),be=t=>{yn.current=t,et(t)},Mt=(0,g.useRef)({approved:0,rejected:0,deferred:0}),[Kr,Ur]=(0,g.useState)(null),je=(0,g.useRef)({added:0,updated:0}),Fe=(0,g.useRef)(!1),se=(0,g.useRef)(null),[ye,_t]=(0,g.useState)(null),Tn=(0,g.useRef)(new Set),$n=fr(),{stdout:Hr}=Me(),Qr=Hr?.columns??80,Rn=(0,g.useRef)(0),N=T!==null,R=T?.review??null,tt=N&&e.state.ledger.at(-1)?.kind==="agent",Ot=(0,g.useRef)(0);(0,g.useEffect)(()=>{let t=i=>R!==null&&i?.kind==="header"&&(i.era??0)>0,n=()=>{let i=e.state.ledger;for(let d=Rn.current;d<i.length;d++){let v=i[d];if(t(v))continue;let _=v.kind==="turn"?yr(e.state.turns,v.turnIndex,N?At:void 0):void 0;N&&_&&_.fresh.length===0&&_.unchanged.length===0||$n.append((0,D.jsx)(Lr,{block:v,annotations:_,remote:N,afterHeader:i[d-1]?.kind==="header"&&!t(i[d-1])||i[d-1]?.kind==="lines"},`lg-${d}`))}Rn.current=i.length};n();let l=e.subscribe(()=>{n();let i=e.state;q.current&&(i.pending||i.status==="pausing")&&(ie(null),i.pending&&b("questions arrived \u2014 back to chat")),P(d=>d+1)});return P(i=>i+1),l},[e,$n]);let{thinking:ge,status:ee,pending:M,confirm:qe,ledger:oe,activeTurn:Cn,stream:Xr,notice:nt}=e.state,Sn=(Xr?.text??"").trimEnd(),En=Sn.length>0,Gr=V&&(ge.liveThinking.length>0||ge.thinkingLog.length>0),zr=cs(ge.liveThinking||ge.thinkingLog.map(t=>t.text).join(`
5
5
  `),Qr-6,Nr),An=En?Sn.split(`
@@ -1,3 +1,3 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as At,b as Ct,d as Ot,f as Tt,t as Mt,u as jt}from"./chunk-7ZJWUWSN.js";import{b as It}from"./chunk-DHYGCHKB.js";import{b as _t,d as Rt}from"./chunk-436FZ4KG.js";import{k as yt}from"./chunk-VQZOKTJ2.js";import{a as ht,b as U}from"./chunk-KRRZCY7U.js";import{c as vt,h as wt}from"./chunk-QQI6N3FO.js";import{c as gt}from"./chunk-ZKPY3AXW.js";import{a as Wt}from"./chunk-HIUAUZNL.js";import{g as Pt,h as Re,j as Et}from"./chunk-DBTMKBHU.js";import{c as Dt,d as $t,e as Ut}from"./chunk-JGLADDRH.js";import{d as xt}from"./chunk-ZGQM6KWN.js";import{g as Nt}from"./chunk-6TNLITJO.js";import{f as bt}from"./chunk-KF4DKXSS.js";import{k as St}from"./chunk-I2VU2DTS.js";import{c as kt}from"./chunk-DPGOAFKF.js";import{B as ct,D as ut,Da as mt,Ha as P,W as _e,ba as pt,f as re,fa as ft,h as rt,i as st,n as k,o as dt,pa as ie,r as Se,t as z,u as se,v as oe,w as lt}from"./chunk-TLOYTGVT.js";import{a as ot,b as it,d as at}from"./chunk-GFLB2SHW.js";import{a as ke}from"./chunk-RQKMSNEU.js";import{a as ne}from"./chunk-I2MC6VVX.js";import{d as et}from"./chunk-2L3A5NKZ.js";import{oa as nt}from"./chunk-Z777GGHB.js";import{b as tt}from"./chunk-6NFOH4AC.js";import{c as Ze}from"./chunk-ZCRZFAOT.js";import{a as Ye}from"./chunk-QMOGBKJM.js";import{appendFileSync as tn,mkdirSync as nn,mkdtempSync as rn,rmSync as sn}from"fs";import{tmpdir as on}from"os";import{dirname as an,join as dn}from"path";import{MessageChannel as ln,Worker as cn}from"worker_threads";var Ft=["submit","submitAnswer","submitFreeText","submitAnswerWithText","toggleOption","confirmMulti","goWithRecommendations","ingestAttach","continueParked","completeSession","requestPause","finalizeForExit","note","ledger"],xn=[...Ft,"state","subscribe","multiSelection","canIngest","senderAlive","aliasOf","explainLines","ask","approveAdded"];function Lt(e,s){let n=s.state,o=s.view,i=new Set,l=[];e.on("message",m=>{if(m.type==="approved")return void l.shift()?.(m.go);if(m.type==="mirror"){n=m.state,o=m.view;for(let g of[...i])g()}});let f=(m,g)=>e.postMessage({type:"controller",member:m,args:g});return{...Object.fromEntries(Ft.map(m=>[m,(...g)=>{f(m,g)}])),get state(){return n},subscribe(m){return i.add(m),()=>i.delete(m)},goWithRecommendations(){return f("goWithRecommendations",[]),{picks:""}},async ingestAttach(m){f("ingestAttach",[m])},approveAdded(){return new Promise(m=>{l.push(m),f("approveAdded",[])})},multiSelection:m=>o.multi[m]??[],canIngest:()=>o.canIngest,senderAlive:()=>o.senderAlive,aliasOf:m=>o.aliases[m],explainLines:()=>null,ask:async()=>{throw new Error("a remote session's questions are asked on its session thread")}}}var Xt=e=>e.added===0?"":e.verb==="design"?`${e.added} added`:`${e.added} ${e.added===1?"use-case":"use-cases"} added`;function On(e,s,n){let o=e.length,i=s.title?`"${s.title}"`:nt(s.id);return[{text:` ${o} other ${o===1?"session is":"sessions are"} open on ${i} \u2014 you can still go ahead`},...Ie(e,n,4)]}function Ie(e,s,n){let o=" ".repeat(n),i=[];for(let l of e){let f=l.owner===null?"":(l.owner==="you"?"yours":"someone else").padEnd(15),j=[Mt[l.state]??l.state,jt(l.lastActivityAt,s),Xt(l)].filter(Boolean);i.push({text:`${o}${f}${j.join(" \xB7 ")}`,dim:!0}),l.owner!=="someone_else"&&(l.state==="ready_to_save"?i.push({text:`${o} save: kane-cli context sessions save ${l.sid}`,dim:!0}):l.state==="paused"&&i.push({text:`${o} resume: ${ie(l.verb==="design"||l.verb==="evolve"?"design":"extract",l.sid,!1)}`,dim:!0}))}return i}var ae=2e3,qt=2*ae,Yt=16;async function $n(e){let s=await xe(e);return s===null?null:s.length===0?P.nothingNewRead.map(n=>({text:n})):[{text:P.nothingNewInSession},...Ie(s,e.now,2)]}function Bt(e){if(e.length===0)return{type:"nothing_new",reason:"every_source_read",next:[{cmd:"kane-cli context ingest <files> --mode agent",why:"add more sources"}]};let s=e.filter(n=>n.owner!=="someone_else").flatMap(n=>n.state==="paused"?[{cmd:`kane-cli context extract --resume ${n.sid} --mode agent`,why:"resume your session"}]:n.state==="ready_to_save"?[{cmd:`kane-cli context sessions save ${n.sid} --yes --mode agent`,why:"save your session"}]:[]);return{type:"nothing_new",reason:"sources_in_a_session",open_sessions:e.map(({sid:n,owner:o,state:i,added:l})=>({sid:n,owner:o,state:i,added:l})),...s.length>0?{next:s}:{}}}async function xe(e){let s,n=new Promise(o=>{s=setTimeout(()=>{e.log?.(`the sources weren't read within ${e.budgetMs??qt} ms; the extract goes on`),o(null)},e.budgetMs??qt)});try{return await Promise.race([Zt(e),n])}catch(o){return e.log?.(`the sources weren't read: ${U(o)}; the extract goes on`),null}finally{clearTimeout(s)}}async function Zt(e){let[s,n]=await Promise.all([e.person.sources(e.projectId),e.person.listSessions(e.projectId)]),o=s.filter(l=>l.head!==null&&!l.sourceId.startsWith(Nt));if(o.length===0||o.some(l=>l.completeness?.sourceCid!==l.head))return null;let i=n.filter(l=>l.verb==="extract");return Rt(e.person,e.projectId,i,e.me,Math.min(Yt,Math.max(1,i.length)))}var Pe=class extends Error{constructor(){super("stopped while the file went up")}},de=class extends Error{constructor(n,o,i){super(n.message);this.refusal=n;this.exit=o;this.detail=i}};async function Sr(){let e=await bt(gt);return{auth:e,preflight:await kt(e)}}var un=500,le=5e3,Ht=6e4,pn=250;function fn(e){let s=e.now-e.pressedAt;if(s>=Ht)return"force";let n=e.saving>0?0:e.now-Math.max(e.quietSince,e.pressedAt);return n>=le?"force":{wait:Math.min(le-n,Ht-s)}}var mn=new Set([k.appendDraft,k.vectorsWrite,k.putBlob,k.chainWrite,k.chainWriteIfAbsent,k.chainRemove,k.filesWrite,k.statePut,k.acknowledge,k.registerChild,k.sideSave]);function gn(){return import.meta.url.endsWith(".ts")?new URL("./session-worker.boot.mjs",import.meta.url):new URL("./session-worker.js",import.meta.url)}function hn(e,s){if(e!=="ingested"||s===null||typeof s!="object")return{kind:e};let n=s,o={kind:e};for(let i of["source_id","status","behind","unread","cursor"])n[i]!==void 0&&(o[i]=n[i]);return o}function vn(e,s){let n=Ze(`remote-${e}`,s);return o=>{try{nn(an(n),{recursive:!0}),tn(n,`${new Date().toISOString()} ${o}
2
+ import{a as At,b as Ct,d as Ot,f as Tt,t as Mt,u as jt}from"./chunk-SXBPUUQ5.js";import{b as It}from"./chunk-6HRNG4CK.js";import{b as _t,d as Rt}from"./chunk-JBKHX5ES.js";import{k as yt}from"./chunk-4CJQ7XZP.js";import{a as ht,b as U}from"./chunk-TAY7J5VS.js";import{c as vt,h as wt}from"./chunk-3RO2YGKH.js";import{c as gt}from"./chunk-NI3TIAD7.js";import{a as Wt}from"./chunk-HIUAUZNL.js";import{g as Pt,h as Re,j as Et}from"./chunk-X2MDL6S4.js";import{c as Dt,d as $t,e as Ut}from"./chunk-YNDELIXL.js";import{d as xt}from"./chunk-LRNUGKYH.js";import{g as Nt}from"./chunk-ZHAMVLQZ.js";import{f as bt}from"./chunk-CB344EDO.js";import{k as St}from"./chunk-L3BUPFAQ.js";import{c as kt}from"./chunk-GBQ4K25P.js";import{B as ct,D as ut,Da as mt,Ha as P,W as _e,ba as pt,f as re,fa as ft,h as rt,i as st,n as k,o as dt,pa as ie,r as Se,t as z,u as se,v as oe,w as lt}from"./chunk-WE7HRAGO.js";import{a as ot,b as it,d as at}from"./chunk-GFLB2SHW.js";import{a as ke}from"./chunk-RQKMSNEU.js";import{a as ne}from"./chunk-4C7WVQOD.js";import{d as et}from"./chunk-7YV2FCN4.js";import{oa as nt}from"./chunk-PI7OXS62.js";import{b as tt}from"./chunk-ZAQGIC33.js";import{c as Ze}from"./chunk-ZCRZFAOT.js";import{a as Ye}from"./chunk-J4FIESTB.js";import{appendFileSync as tn,mkdirSync as nn,mkdtempSync as rn,rmSync as sn}from"fs";import{tmpdir as on}from"os";import{dirname as an,join as dn}from"path";import{MessageChannel as ln,Worker as cn}from"worker_threads";var Ft=["submit","submitAnswer","submitFreeText","submitAnswerWithText","toggleOption","confirmMulti","goWithRecommendations","ingestAttach","continueParked","completeSession","requestPause","finalizeForExit","note","ledger"],xn=[...Ft,"state","subscribe","multiSelection","canIngest","senderAlive","aliasOf","explainLines","ask","approveAdded"];function Lt(e,s){let n=s.state,o=s.view,i=new Set,l=[];e.on("message",m=>{if(m.type==="approved")return void l.shift()?.(m.go);if(m.type==="mirror"){n=m.state,o=m.view;for(let g of[...i])g()}});let f=(m,g)=>e.postMessage({type:"controller",member:m,args:g});return{...Object.fromEntries(Ft.map(m=>[m,(...g)=>{f(m,g)}])),get state(){return n},subscribe(m){return i.add(m),()=>i.delete(m)},goWithRecommendations(){return f("goWithRecommendations",[]),{picks:""}},async ingestAttach(m){f("ingestAttach",[m])},approveAdded(){return new Promise(m=>{l.push(m),f("approveAdded",[])})},multiSelection:m=>o.multi[m]??[],canIngest:()=>o.canIngest,senderAlive:()=>o.senderAlive,aliasOf:m=>o.aliases[m],explainLines:()=>null,ask:async()=>{throw new Error("a remote session's questions are asked on its session thread")}}}var Xt=e=>e.added===0?"":e.verb==="design"?`${e.added} added`:`${e.added} ${e.added===1?"use-case":"use-cases"} added`;function On(e,s,n){let o=e.length,i=s.title?`"${s.title}"`:nt(s.id);return[{text:` ${o} other ${o===1?"session is":"sessions are"} open on ${i} \u2014 you can still go ahead`},...Ie(e,n,4)]}function Ie(e,s,n){let o=" ".repeat(n),i=[];for(let l of e){let f=l.owner===null?"":(l.owner==="you"?"yours":"someone else").padEnd(15),j=[Mt[l.state]??l.state,jt(l.lastActivityAt,s),Xt(l)].filter(Boolean);i.push({text:`${o}${f}${j.join(" \xB7 ")}`,dim:!0}),l.owner!=="someone_else"&&(l.state==="ready_to_save"?i.push({text:`${o} save: kane-cli context sessions save ${l.sid}`,dim:!0}):l.state==="paused"&&i.push({text:`${o} resume: ${ie(l.verb==="design"||l.verb==="evolve"?"design":"extract",l.sid,!1)}`,dim:!0}))}return i}var ae=2e3,qt=2*ae,Yt=16;async function $n(e){let s=await xe(e);return s===null?null:s.length===0?P.nothingNewRead.map(n=>({text:n})):[{text:P.nothingNewInSession},...Ie(s,e.now,2)]}function Bt(e){if(e.length===0)return{type:"nothing_new",reason:"every_source_read",next:[{cmd:"kane-cli context ingest <files> --mode agent",why:"add more sources"}]};let s=e.filter(n=>n.owner!=="someone_else").flatMap(n=>n.state==="paused"?[{cmd:`kane-cli context extract --resume ${n.sid} --mode agent`,why:"resume your session"}]:n.state==="ready_to_save"?[{cmd:`kane-cli context sessions save ${n.sid} --yes --mode agent`,why:"save your session"}]:[]);return{type:"nothing_new",reason:"sources_in_a_session",open_sessions:e.map(({sid:n,owner:o,state:i,added:l})=>({sid:n,owner:o,state:i,added:l})),...s.length>0?{next:s}:{}}}async function xe(e){let s,n=new Promise(o=>{s=setTimeout(()=>{e.log?.(`the sources weren't read within ${e.budgetMs??qt} ms; the extract goes on`),o(null)},e.budgetMs??qt)});try{return await Promise.race([Zt(e),n])}catch(o){return e.log?.(`the sources weren't read: ${U(o)}; the extract goes on`),null}finally{clearTimeout(s)}}async function Zt(e){let[s,n]=await Promise.all([e.person.sources(e.projectId),e.person.listSessions(e.projectId)]),o=s.filter(l=>l.head!==null&&!l.sourceId.startsWith(Nt));if(o.length===0||o.some(l=>l.completeness?.sourceCid!==l.head))return null;let i=n.filter(l=>l.verb==="extract");return Rt(e.person,e.projectId,i,e.me,Math.min(Yt,Math.max(1,i.length)))}var Pe=class extends Error{constructor(){super("stopped while the file went up")}},de=class extends Error{constructor(n,o,i){super(n.message);this.refusal=n;this.exit=o;this.detail=i}};async function Sr(){let e=await bt(gt);return{auth:e,preflight:await kt(e)}}var un=500,le=5e3,Ht=6e4,pn=250;function fn(e){let s=e.now-e.pressedAt;if(s>=Ht)return"force";let n=e.saving>0?0:e.now-Math.max(e.quietSince,e.pressedAt);return n>=le?"force":{wait:Math.min(le-n,Ht-s)}}var mn=new Set([k.appendDraft,k.vectorsWrite,k.putBlob,k.chainWrite,k.chainWriteIfAbsent,k.chainRemove,k.filesWrite,k.statePut,k.acknowledge,k.registerChild,k.sideSave]);function gn(){return import.meta.url.endsWith(".ts")?new URL("./session-worker.boot.mjs",import.meta.url):new URL("./session-worker.js",import.meta.url)}function hn(e,s){if(e!=="ingested"||s===null||typeof s!="object")return{kind:e};let n=s,o={kind:e};for(let i of["source_id","status","behind","unread","cursor"])n[i]!==void 0&&(o[i]=n[i]);return o}function vn(e,s){let n=Ze(`remote-${e}`,s);return o=>{try{nn(an(n),{recursive:!0}),tn(n,`${new Date().toISOString()} ${o}
3
3
  `)}catch{}}}var w=U;async function wn(e,s,n,o){let i,l;try{[i,l]=await Promise.all([pt(e.person,s,n),e.person.getSession(n)])}catch(f){return o(`the session that added nothing was not discarded: ${w(f)}`),!0}if(ft(i,(l.scope?.position??l.basePosition)>l.basePosition))return!0;try{await e.person.discard(n,e.claim.generation)}catch(f){o(`the session that added nothing was not discarded: ${w(f)}`)}return!1}function yn(e,s){return e===0&&s>0?1:e}async function _r(e){let s={trace:Dt(null,"")},n=1;Se({projectId:e.choice.projectId});try{return n=await bn(e,s),n}finally{s.trace.line("run_end",{code:n}),await lt()}}async function bn(e,s){let n=e.testing??{},o=null,i=new Set,l=r=>{if(r.type!=="session_paused"||e.verb!=="extract"||i.size<2)return r;let{resume:a,held_review:y,next:Y,...$}=r,Z=Ot(e.ingest?.map(ee=>ee.path??ee.file),A?.record??null),G=A?.record.sessionId??String(r.sid);return{...$,sid:G,...Tt(G,Z)}},f=r=>{let a=e.io?At(r,Date.now(),{sourceId:A?.record.sourceId??null,mode:e.mode}):null;a&&e.io.event(l(a)),e.onProgress(o!==null&&r.kind==="load"?{kind:"reading",file:o}:r)},j=e.start.kind==="resume"?e.start.sessionId:null,N=null,m=null,g=null,Ee=!1,ce=null,Ae=[],W=!1,ue=!1,pe=null,fe=!1,A=null,u=n.diagnostics??(()=>{}),C=(r,a={})=>{e.io?e.io.event({type:"error",code:r.code,message:r.message,...ct(r),...r.heldBy?{held_by:ut(r.heldBy)}:{},...r.notAdded?{not_added:r.notAdded}:{},...a}):e.onRefusal?e.onRefusal(r):yt(r)},Gt=r=>{if(!g){if(g=r,e.onEnding?.(),u(`the session's writer was stopped: ${U(r)}`),z(se(r),oe(r)),m?.close(P.stepRefused),r.code==="PROJECT_NOT_MARKED")Ee=!0;else if(r.code==="SESSION_ENDED"||r.code==="SCOPE_NOT_OPEN")pe=r;else{let a=r.code===rt?"resumed_elsewhere":r.code===st?"computer_slept":"connection_lost";W&&a==="connection_lost"?ue=!0:f({kind:"paused",reason:a,sid:A?.record.sessionId??j??""})}setTimeout(()=>{N?.terminate()},le).unref()}},E=!1,S=!1,me=0,ge=new Set,D=0,Ce=!1,J=!1,Oe=()=>{},Kt=new Promise(r=>Oe=r),Te=()=>{E=!0,N?.postMessage({type:"stop"})},Me=()=>{},je=new Promise(r=>Me=r),he=()=>{s.trace.line("run_forced",{}),S=!0,Me(),J&&Oe();let r=N;r?.postMessage({type:"kill"}),setTimeout(()=>{r?.terminate()},pn).unref()},ve=0,Ne=r=>{let a=()=>{if(S||Ce)return;let y=fn({now:Date.now(),pressedAt:r,saving:me+ge.size,quietSince:D});if(y==="force")return he();setTimeout(a,Math.max(50,y.wait)).unref()};setTimeout(a,le).unref()},We=()=>{if(ve+=1,s.trace.line("stop_asked",{by:"ctrl_c",press:ve}),J||ve>1)return he();Te(),Ne(Date.now())};e.onControls?.({pause:()=>{s.trace.line("stop_asked",{by:"pause"}),E=!0,Ne(Date.now())},force:he});let _=!1,De=null,$e=0;if(e.mode==="agent"&&e.io&&e.verb==="extract"&&e.start.kind==="new"&&!e.start.body.sourceId&&!e.run.force&&!e.ingest){let r=await xe({person:re({url:e.choice.latticeUrl,basicAuth:e.basicAuth,requestDeadlineMs:ae,...n.fetch?{fetch:n.fetch}:{}}),projectId:e.choice.projectId,me:vt(process.cwd()),now:Date.now(),log:n.diagnostics??ht("nothing-new")});if(r!==null)return e.io.event(Bt(r)),0}let F=e.io?await tt({event:r=>e.io.event(r)},e.check):await e.check();if(!F.preflight.ok){let{cause:r,final:a}=F.preflight;return u(`the controller's check refused the run: ${F.preflight.message}`),C(P.preflight(r??(a?"rejected":"unreachable")),{final:a}),2}if(S)return 130;let Vt=e.signals?process.listeners("SIGINT"):[],Q=!1,Ue=()=>{!e.signals||Q||(Q=!0,process.removeAllListeners("SIGINT"),process.on("SIGINT",We))},L=()=>{if(Q){Q=!1,process.removeListener("SIGINT",We);for(let r of Vt)process.on("SIGINT",r)}},q=null,X=[];if(e.ingest){Ue();try{for(let a of e.ingest){if(!a.fetch)continue;if(await Promise.race([a.fetch(f).then(()=>!0),je.then(()=>null)])===null||S||E)return L(),130}let r=[];for(let a of e.ingest){if(a.deferred){r.push(null);continue}let y=await Promise.race([a.upload(f,()=>E||S),je.then(()=>null)]);if(y===null||S)return L(),130;r.push(y)}q=r}catch(r){if(L(),r instanceof Pe)return 130;if(!(r instanceof de))throw r;return u(`the upload was refused: ${r.detail??r.message}`),C(r.refusal),r.exit}}try{A=await _t({url:e.choice.latticeUrl,basicAuth:e.basicAuth,start:e.start,...e.choice.projectName?{projectName:e.choice.projectName}:{},onProgress:f,onStopped:Gt,log:r=>u(r),testing:{...n.fetch?{fetch:n.fetch}:{},...n.leaseRenewMs!==void 0?{leaseRenewMs:n.leaseRenewMs}:{},...n.retryDeadlineMs!==void 0?{retryDeadlineMs:n.retryDeadlineMs}:{}}})}catch(r){L(),e.choice.onboarded&&r instanceof ne&&(r.code==="MARK_REFUSED"||r.code==="PROJECT_NOT_MARKED")&&wt(process.cwd());let a=await Rn(r,{latticeUrl:e.choice.latticeUrl,projectId:e.choice.projectId,basicAuth:e.basicAuth,sessionId:j,useCase:e.run.useCase,log:$=>u($),...n.fetch?{fetch:n.fetch}:{}}),{exit:y,...Y}=It(r,e.choice,j,e.verb==="reconcile"?void 0:{verb:e.verb,...(e.verb==="design"||e.verb==="evolve")&&e.run.useCase?{useCase:e.run.useCase}:{},...a!==void 0?{title:a}:{},...e.mode==="agent"?{agent:!0}:{}});return u(`the session could not be opened: ${w(r)}`),r instanceof ne&&z(se(r),oe(r)),C(Y),y}let c=A,p=c.record.sessionId;Se({latticeSessionId:p,projectId:e.choice.projectId});let Fe=e.start.kind==="resume"&&c.record.verb==="reconcile"&&c.record.sourceId!==null,B=Fe?_n({...c.record,sourceId:c.record.sourceId}):null;Fe&&e.io?.retag?.("reconcile");let H=e.start.kind==="resume"&&c.record.verb==="evolve";H&&e.io?.retag?.("evolve");let Le=H?Sn(c.log.since(0)):void 0;if(H)for(let[r,a]of _e(c.log.since(0)))e.onRepinned?.(r,a);n.diagnostics||(u=vn(e.verb,p)),s.trace=$t(e.traceVerb??e.verb,ke()),s.trace.path&&Ut(p,s.trace.path),s.trace.line("run_open",{sid:p,verb:e.verb,start:e.start.kind,mode:e.mode??"interactive",cli_version:Ye,env:et(),project_id:e.choice.projectId});{let r=u;u=a=>{r(a),s.trace.line("diag",{line:a})}}let qe=rn(dn(on(),"kane-remote-session-")),we=[],Be=!1;Ue();let He=async()=>{if(!(!e.ingest||q===null))for(let[r,a]of e.ingest.entries())X[r]||(X[r]=!0,await a.cancel(p).catch(y=>u(`the upload's cancel was not posted: ${w(y)}`)))},ye=()=>(e.start.kind==="new"?c.person.discard(p,c.claim.generation):c.person.setStatus(p,"paused")).then(()=>{},r=>u(`the unstarted session was not put away: ${w(r)}`)),Ge=async()=>(await c.person.setStatus(p,"paused").catch(r=>u(`the pause was not recorded: ${w(r)}`)),f({kind:"not_ended",sid:p,project:e.choice.projectName}),1),Ke=async()=>{let r=await c.person.getSession(p).then(y=>y.scope?.state,()=>null);return f({kind:"ended",reason:r==="finalized"?"saved_elsewhere":r==="discarded"?"discarded_elsewhere":"ended_elsewhere",sid:p}),0},zt=async()=>{let r=await c.client.sessionState().catch(a=>(u(`the session's state couldn't be read: ${w(a)}`),null));return r===null||typeof r.completed_at!="string"?null:r.ended?.ended==="failed"?"failed":"complete"};try{if(S)return await He(),await ye(),130;try{e.onOpened?.(c.record,d=>u(d))}catch(d){u(`the folder's project link could not be updated: ${w(d)}`)}let r=e.start.kind==="resume"?await zt():null;if(r!==null){J=!0,W=!0;try{await c.state.end(p,{state:r,panel:null,error:null,checkIn:!1,phase:null,child:null,pausing:!1})}catch(d){return u(`the ending was not recorded: ${w(d)}`),pe?await Ke():g&&!ue?3:await Ge()}return r==="failed"?(C(P.sessionFailed(p)),2):(f({kind:"finished_before",sid:p}),0)}let a=0,y=async(d,b)=>{let T=mn.has(d),v=String(b?.childId??"");d===k.chainWrite&&/^(delta|full)-\d+\.json$/.test(String(b?.name))&&ge.add(v),T&&(me+=1,D=Date.now());let R=d===k.appendDraft,K;R&&(a+=1,e.onWrites?.(a),K=setTimeout(()=>f({kind:"write",pending:a}),300));try{return await c.storeCalls(d,b)}catch(I){throw u(`${d} was refused: ${w(I)}`),I instanceof ot?I:(z(se(I),oe(I)),I instanceof dt&&!g&&(fe=!0,e.onEnding?.()),it(new Error(P.stepRefused),I))}finally{d===k.acknowledge&&ge.delete(v),T&&(me-=1,D=Date.now()),R&&(clearTimeout(K),a-=1,e.onWrites?.(a),a===0&&f({kind:"write",pending:0}))}},{port1:Y,port2:$}=new ln,Z=new SharedArrayBuffer(4);m=at({port:Y,signal:Z},y);let G=H||e.verb==="evolve"?await kn(re({url:e.choice.latticeUrl,basicAuth:e.basicAuth,requestDeadlineMs:ae,...n.fetch?{fetch:n.fetch}:{}}),e.choice.projectId,u):void 0,ee={verb:B?"reconcile":H?"evolve":e.verb,traceVerb:e.traceVerb??e.verb,mode:e.mode,sessionId:p,fresh:e.start.kind==="new",generation:c.claim.generation,projectDir:process.cwd(),projectName:e.choice.projectName,projectId:e.choice.projectId,sideDir:qe,bridge:{port:$,signal:Z},lastEventSeq:c.log.lastSeq(),run:e.start.kind==="resume"?{...e.run,resume:p,...Le!==void 0?{kept:Le,...c.record.useCase?{useCase:c.record.useCase}:{}}:{}}:e.run,...e.start.kind==="resume"&&e.verb==="extract"?{landed:[...new Set((c.record.uploads??[]).filter(d=>d.outcome!=="refused").map(d=>d.sourceId))]}:{},auth:F.auth,preflight:F.preflight,supportId:ke(),...n.agent||n.remoteDeps||n.sourcePlugins||n.refuseCard?{testing:{...n.agent?{agent:n.agent}:{},...n.remoteDeps?{remoteDeps:n.remoteDeps}:{},...n.sourcePlugins?{sourcePlugins:n.sourcePlugins}:{},...n.refuseCard?{refuseCard:n.refuseCard}:{}}}:{},...e.ingest&&q?{ingest:e.ingest.map((d,b)=>({bytes:new Uint8Array(d.bytes),file:d.file,sourceId:d.sourceId,fingerprint:q[b]?.fingerprint??"",then:d.then,...d.remote?{remote:d.remote}:{},...d.plugin?{plugin:d.plugin}:{}}))}:{},...B?{review:B}:{},...G?{origins:G}:{}},Ve=()=>e.io?.event({type:"error",message:P.runStopped(e.verb)}),O=await new Promise(d=>{let b=!1,T=t=>{b||(b=!0,d(t))},v;try{v=new cn(n.workerUrl??gn(),{workerData:ee,transferList:[$]})}catch(t){return u(`the session thread could not start: ${w(t)}`),Ve(),T(1)}N=v,E&&v.postMessage({type:"stop"});let R=e.ingest?.[0],K=R?.remote?Pt({...R.remote,address:R.remote.origin.url},Re(R.remote.provider,R.remote.origin.url,R.sourceId)):void 0,I=B??(e.verb==="reconcile"&&R?{sourceId:R.sourceId,file:R.path??R.file,...K?{page:K}:{}}:null);if(e.onReview&&I){let t=Wt(v),x={source:I.sourceId,file:I.file,...I.page?{page:I.page}:{}};e.onReview(t,x);let h=!1;v.on("message",V=>{if(h||V.type!=="reviewMirror"||!V.review.named)return;h=!0;let M=xt(x,V.review.named);M&&e.onReview(t,M)})}e.ingest&&(o=e.ingest[0].file,f({kind:"reading",file:o})),n.terminateOnHold?.then(()=>v.terminate());let Qe=!0,Xe=!1;v.on("message",t=>{if(t.type==="mirror"&&E&&t.state.nestedAgent===!0&&(D=Date.now()),t.type==="mirror"&&!Xe)Xe=!0,e.onController?.(Lt(v,{state:t.state,view:t.view}));else if(t.type==="event"){if(E&&t.event.child_id!==void 0&&(D=Date.now()),(fe||g)&&t.event.type==="error")return u(`after the run paused: ${String(t.event.message??"")}`);if(e.start.kind==="resume"&&t.event.type==="error"&&mt.has(String(t.event.code??"")))return ce=String(t.event.code),u(`the resume was refused: ${String(t.event.message??"")}`);if(t.event.type==="held"&&e.onHeld?.(Number(t.event.count)||0),t.event.type==="session_complete"&&e.mode==="agent"||(t.event.type==="source_start"&&i.add(String(t.event.source_id)),t.event.type==="child_start"?we.push({child:t.event.child,at:Date.now()}):t.event.type==="child_end"?we.pop():t.event.type==="session_paused"&&t.event.child_id===void 0&&(Be=!0),t.event.type==="run_start"&&t.event.child_id!==void 0))return;e.io?.event(l(t.event.type==="run_start"?{type:"run_start",session:p}:t.event.type==="session_paused"&&t.event.held!==void 0?{...t.event,reason:"held_back"}:t.event.type==="held"&&t.event.reason==="embed_degraded"?{...t.event,reason:"duplicate_check_reduced"}:t.event.type==="held"&&t.event.reason==="reconcile"?{...t.event,reason:"review"}:t.event)),(Qe&&n.stopAfterFirstEvent||!E&&t.event.type===n.stopAtEvent)&&Te(),Qe=!1}else if(t.type==="summary")e.onSummary?.(t.facts);else if(t.type==="notUpdated")e.onNotUpdated?.(t.useCases,t.titles,t.stillStale);else if(t.type==="unstarted")_=!0;else if(t.type==="needed")Ae=t.needed.noStartPage.map(({test:x})=>({test:x})),e.onNeeded?.({needed:t.needed,tests:t.tests});else if(t.type==="preMount")(e.onPreMount?e.onPreMount(t.question):Promise.resolve({go:!1,code:2})).then(x=>{!x.go&&t.question.kind!=="evolve-entry"&&t.question.kind!=="lines"&&(_=!0),v.postMessage({type:"preMountAnswer",answer:x})});else if(t.type==="ingestFetched"){let x=e.ingest[t.index];x.bytes=Buffer.from(t.bytes),x.upload(f,()=>E||S).then(h=>{q[t.index]=h,v.postMessage({type:"ingestUploaded",index:t.index,ok:!0,fingerprint:h.fingerprint})},h=>{h instanceof de?(u(`the upload was refused: ${h.detail??h.message}`),C(h.refusal),De=h.exit):u(`the fetched item's upload failed: ${w(h)}`),X[t.index]=!0,_=!0,v.postMessage({type:"ingestUploaded",index:t.index,ok:!1})})}else if(t.type==="ingestOutcome"){let{type:x,index:h,...V}=t;X[h]=!0,e.ingest[h].result(V,p,u).then(M=>{M?e.ingest[h+1]&&(o=e.ingest[h+1].file,f({kind:"reading",file:o})):(_=!0,o=null),v.postMessage({type:"ingestGo",index:h,go:M})},M=>{u(`the upload's result was not posted: ${w(M)}`),_=!0,v.postMessage({type:"ingestGo",index:h,go:!1})})}else if(t.type==="ingested")o=null,e.verb==="reconcile"&&t.status==="unchanged"&&!t.behind&&!t.unread&&(_=!0),e.ingest?.[t.index]?.onAdded?.(t.status,p,{...t.duplicateOf?{duplicateOf:t.duplicateOf}:{},...t.attachments?{attachments:t.attachments}:{},...t.behind?{behind:t.behind}:{},...t.unread?{unread:!0}:{}});else if(t.type==="ingestUnwritten")o=null,_=!0,e.ingest?.[t.index]?.onUnwritten?.(p);else if(t.type==="sessionEvent"){E&&t.payload.child_id!==void 0&&(D=Date.now()),c.log.append(t.kind,t.payload),s.trace.line("session_event",hn(t.kind,t.payload));for(let[x,h]of _e([t]))e.onRepinned?.(x,h)}else t.type==="itemsFailed"?$e+=t.count:t.type==="out"?e.io?.out(t.line):t.type==="log"?u(t.line):t.type==="done"&&T(De??t.code)}),v.on("error",t=>{u(`the session thread failed: ${t instanceof Error&&t.stack?t.stack:w(t)}`),z("thread_crash"),Ve(),T(1)}),v.on("exit",()=>{s.trace.line("thread_exit",{stopped:g!==null,forced:S}),T(g?3:S?130:1)})});J=!0;let ze=e.ingest?.[0]?.then==="pause";W=O===0&&!_&&!ze;let te=O!==0||_,Jt=fe&&!g&&!S&&O!==0&&!_,be=!1,Qt=async()=>{await He(),_?(await c.log.flush().catch(()=>{}),await ye()):O!==0&&!g&&await c.person.setStatus(p,"paused").catch(d=>u(`the pause was not recorded: ${w(d)}`)),await c.log.flush(),!g&&O===0&&!_&&(ze?await c.person.setStatus(p,"paused"):await c.state.end(p,{state:"complete",panel:null,error:null,checkIn:!1,phase:null,child:null,pausing:!1}),te=!0),be=!0};await Promise.race([Qt().catch(d=>u(`the run's ending was not recorded: ${w(d)}`)),Kt]);let Je=!0;if(e.mode==="agent"&&be&&W&&te&&!g&&!S&&(Je=await wn(c,e.choice.projectId,p,u)),S&&!be&&!g){let d=_?ye():c.person.setStatus(p,"paused").catch(b=>u(`the pause was not recorded: ${w(b)}`));await Promise.race([d,new Promise(b=>setTimeout(b,un).unref())])}if(Ee)return C(P.assuranceOff(e.choice.projectName)),2;if(ce!==null)return C(P.resumeUnreadable(ce,p,e.verb==="design"?"design":"extract",c.record.useCase)),2;if(pe)return await Ke();if(S){if(e.mode!=="agent"||g||_)return 130;if(Be)return 3;for(let b of we.splice(0).reverse())e.io?.event({type:"child_end",child:b.child,ok:!1,dur_s:Math.max(1,Math.round((Date.now()-b.at)/1e3)),exit_code:3});let d=ie(e.verb==="design"&&!B?"design":"extract",p,!0);return e.io?.event(l({type:"session_paused",sid:p,...c.record.sourceId?{source_id:c.record.sourceId}:{},mode:"agent",resume:d,expires_at:null,pending_questions:[],next:[{cmd:d,why:"resume"}]})),3}return ue||W&&!te&&!g?await Ge():g?3:Jt?(f({kind:"paused",reason:"not_accepted",sid:p}),3):te?(e.mode==="agent"&&W&&O===0&&e.io?.event(Ct(p,Je,{sourceId:A?.record.sourceId??null,noStartPage:Ae})),yn(O,$e)):(f({kind:"paused",reason:"connection_lost",sid:p}),3)}finally{Ce=!0,L(),c.release(),m?.close("the session ended"),await N?.terminate(),sn(qe,{recursive:!0,force:!0})}}async function kn(e,s,n){try{return Object.fromEntries((await e.sources(s)).map(o=>[o.sourceId,o.origin?.url??null]))}catch(o){return n(`the project's sources were not read: ${w(o)}`),{}}}function Sn(e){let s=e.filter(i=>i.kind==="evolve_answers").at(-1)?.payload,n=s?.request;if(!n||!Array.isArray(s?.answers))return"unread";let o=s.answers.flatMap(i=>typeof i.id=="string"&&(i.choice==="proceed"||i.choice==="decline")?[{id:i.id,choice:i.choice}]:[]);return{request:{...typeof n.ref=="string"?{ref:n.ref}:{},fromStale:n.fromStale===!0,...typeof n.because=="string"?{because:n.because}:{}},answers:o}}function _n(e){let s=[...e.uploads??[]].reverse().find(n=>n.sourceId===e.sourceId&&n.outcome!=="refused"&&(n.filename||n.originUrl));if(s&&!s.filename&&s.originUrl){let n=s.originUrl,o=St(n)?.name??"web";return{sourceId:e.sourceId,file:n,page:Et(o,n,void 0,Re(o,n,e.sourceId))}}return{sourceId:e.sourceId,file:s?.filename??"<file>"}}async function Rn(e,s){if(!(e instanceof ne)||e.code!=="SESSION_CLASH")return;let n=e.extra.heldBy;if(n?.verb!=="design"&&n?.verb!=="evolve")return;let o=re({url:s.latticeUrl,basicAuth:s.basicAuth,...s.fetch?{fetch:s.fetch}:{}});try{if(s.sessionId!==null)return(await o.getSession(s.sessionId)).useCaseTitle??null;if(!s.useCase)return null;let i=(await o.mainNode(s.projectId,s.useCase)).content.title;return typeof i=="string"&&i!==""?i:null}catch(i){return s.log(`the use case's title couldn't be read for the lock's words, so they name its id: ${U(i)}`),null}}export{On as a,ae as b,$n as c,Pe as d,de as e,Sr as f,fn as g,mn as h,hn as i,yn as j,_r as k};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as s}from"./chunk-HCBYKLMW.js";import{a as m,b as o}from"./chunk-33DWJV67.js";import{z as i}from"./chunk-QMOGBKJM.js";import{e as x}from"./chunk-UR6MHSHU.js";var t=x(s(),1);function d({label:r,text:c,accent:a,color:n,width:l=15}){return(0,t.jsxs)(o,{children:[(0,t.jsx)(o,{color:i.dim,children:` ${r.padEnd(l)}`}),(0,t.jsx)(o,{color:n??(a?i.assuranceAccent:void 0),children:c})]})}function u({head:r,rows:c,minWidth:a=15}){let n=c.filter(e=>e.text),l=Math.max(a,...n.map(e=>e.label.length+2));return(0,t.jsxs)(m,{flexDirection:"column",children:[r?(0,t.jsx)(o,{bold:!0,children:r}):null,n.map((e,p)=>(0,t.jsx)(d,{label:e.label,text:e.text,color:e.color,width:l},p))]})}export{d as a,u as b};
2
+ import{a as s}from"./chunk-HCBYKLMW.js";import{a as m,b as o}from"./chunk-33DWJV67.js";import{z as i}from"./chunk-J4FIESTB.js";import{e as x}from"./chunk-UR6MHSHU.js";var t=x(s(),1);function d({label:r,text:c,accent:a,color:n,width:l=15}){return(0,t.jsxs)(o,{children:[(0,t.jsx)(o,{color:i.dim,children:` ${r.padEnd(l)}`}),(0,t.jsx)(o,{color:n??(a?i.assuranceAccent:void 0),children:c})]})}function u({head:r,rows:c,minWidth:a=15}){let n=c.filter(e=>e.text),l=Math.max(a,...n.map(e=>e.label.length+2));return(0,t.jsxs)(m,{flexDirection:"column",children:[r?(0,t.jsx)(o,{bold:!0,children:r}):null,n.map((e,p)=>(0,t.jsx)(d,{label:e.label,text:e.text,color:e.color,width:l},p))]})}export{d as a,u as b};