@testmuai/kane-cli 0.10.0-rc.3 → 0.10.2

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 (421) hide show
  1. package/dist/ChatSurface-FIYDTZSI.js +2 -0
  2. package/dist/{ChromeProfilePicker-M4WXOB5O.js → ChromeProfilePicker-Q6FIGVYU.js} +1 -1
  3. package/dist/{CliFeedbackPrompt-6MJA7DF6.js → CliFeedbackPrompt-2NV2G65E.js} +1 -1
  4. package/dist/{CliUploadProgress-6NLS7XHH.js → CliUploadProgress-JZ5FXODE.js} +1 -1
  5. package/dist/{ConfigView-O4WKZ5PU.js → ConfigView-TZ4YINOE.js} +1 -1
  6. package/dist/EvidenceViewOffer-LKPN5BHX.js +2 -0
  7. package/dist/FolderPicker-H5K74PCH.js +2 -0
  8. package/dist/InfoBox-DNSOAK5L.js +2 -0
  9. package/dist/{LinksBox-DXP66H3H.js → LinksBox-32TZOANP.js} +1 -1
  10. package/dist/{ProfilesView-TWOY5PVC.js → ProfilesView-UC4MPM54.js} +1 -1
  11. package/dist/ProjectPicker-ZJ5RW6XL.js +2 -0
  12. package/dist/SaveSessionPrompt-F327WC7A.js +2 -0
  13. package/dist/SingleShotApp-OMLRYOSI.js +2 -0
  14. package/dist/{SummaryBox-IA2KS6GT.js → SummaryBox-XGFO5X76.js} +1 -1
  15. package/dist/TestMdRunView-ZZ77QTAQ.js +2 -0
  16. package/dist/TestrunEvidenceTable-G7MPF55X.js +2 -0
  17. package/dist/{WhoamiView-SNL75TEF.js → WhoamiView-4XIJXMTU.js} +1 -1
  18. package/dist/{app-download-UI4ABEIX.js → app-download-XEDO3EMV.js} +1 -1
  19. package/dist/{assurance-job-FFSSS4XV.js → assurance-job-MD65GQLC.js} +1 -1
  20. package/dist/{auth-7Z54TMQQ.js → auth-WBIEHHDS.js} +1 -1
  21. package/dist/{binary-THPLXCOD.js → binary-NVYLR36K.js} +1 -1
  22. package/dist/bind-H3ALI2NG.js +2 -0
  23. package/dist/bootstrap-JEVSVPQ2.js +2 -0
  24. package/dist/bridge-2UHJOVLX.js +2 -0
  25. package/dist/{catalog-MYPS2BXY.js → catalog-5UYBWA4W.js} +1 -1
  26. package/dist/catalog-client-VVKV4JKW.js +2 -0
  27. package/dist/{changelog-SU674BVE.js → changelog-FPWJXERY.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-226AGYHB.js +87 -0
  32. package/dist/{chunk-MNBGG4H3.js → chunk-23DKB2MT.js} +1 -1
  33. package/dist/{chunk-EECDDDSB.js → chunk-2COXO5LQ.js} +1 -1
  34. package/dist/{chunk-LUR7JFPP.js → chunk-2GEAKFAV.js} +1 -1
  35. package/dist/{chunk-7SY34IIL.js → chunk-2QKBXRLI.js} +1 -1
  36. package/dist/{chunk-AVSMXDTX.js → chunk-2ULYGALF.js} +1 -1
  37. package/dist/{chunk-JNSWKGTB.js → chunk-32HED7X2.js} +1 -1
  38. package/dist/{chunk-GRURFGBP.js → chunk-32MFECUA.js} +1 -1
  39. package/dist/{chunk-MYVKUJGS.js → chunk-35BG2EMW.js} +1 -1
  40. package/dist/{chunk-3GXN6VF6.js → chunk-3KY7HHQU.js} +1 -1
  41. package/dist/{chunk-7NPTL66J.js → chunk-3V4J65GN.js} +1 -1
  42. package/dist/{chunk-457Y5TEC.js → chunk-3YIA3DSL.js} +1 -1
  43. package/dist/{chunk-36N3EHW5.js → chunk-44SIFDNY.js} +1 -1
  44. package/dist/{chunk-MEKPGQAM.js → chunk-45NM23EQ.js} +2 -2
  45. package/dist/{chunk-I2MC6VVX.js → chunk-4C7WVQOD.js} +1 -1
  46. package/dist/{chunk-TU42YZOJ.js → chunk-4HARMERK.js} +1 -1
  47. package/dist/{chunk-ICLUC44J.js → chunk-4HYPMGDF.js} +1 -1
  48. package/dist/{chunk-7KX2BHKG.js → chunk-4KCYNP2K.js} +1 -1
  49. package/dist/{chunk-IJ2AHSWW.js → chunk-4LGQHTXM.js} +1 -1
  50. package/dist/{chunk-ETZMFRD6.js → chunk-4NEPHIAO.js} +1 -1
  51. package/dist/{chunk-3E4ZO73O.js → chunk-54NJJVG5.js} +1 -1
  52. package/dist/{chunk-734ORT6O.js → chunk-5F44KH3R.js} +1 -1
  53. package/dist/{chunk-E6KSRQXL.js → chunk-5F5IVART.js} +1 -1
  54. package/dist/{chunk-EBPRPNSA.js → chunk-5KJU4MG4.js} +1 -1
  55. package/dist/{chunk-JZP3Y4ZM.js → chunk-5MFPQYW3.js} +1 -1
  56. package/dist/{chunk-QENCC2ZS.js → chunk-5WLXAQ4H.js} +1 -1
  57. package/dist/{chunk-RFEON5GN.js → chunk-5XVWT6UK.js} +1 -1
  58. package/dist/{chunk-W4QSZNMB.js → chunk-6CS23F3E.js} +1 -1
  59. package/dist/{chunk-DZOYYWOW.js → chunk-6JUS2ULI.js} +1 -1
  60. package/dist/chunk-6K5BEEAJ.js +2 -0
  61. package/dist/{chunk-4QFTHUJA.js → chunk-6LEHGRRG.js} +1 -1
  62. package/dist/{chunk-LSDJOVWW.js → chunk-6SD4XTYC.js} +1 -1
  63. package/dist/{chunk-TW5AA5A7.js → chunk-6SWHEBPR.js} +1 -1
  64. package/dist/{chunk-URH4FX3H.js → chunk-6YBH3WUW.js} +1 -1
  65. package/dist/{chunk-ZAFJQ3SM.js → chunk-73HMW2WA.js} +1 -1
  66. package/dist/{chunk-NXAJBSIF.js → chunk-75FF7J5R.js} +1 -1
  67. package/dist/{chunk-P3JXJ4BW.js → chunk-7DLDADQR.js} +1 -1
  68. package/dist/{chunk-7NCJMWFX.js → chunk-7LYLJ75Z.js} +1 -1
  69. package/dist/chunk-7O2FIZB7.js +9 -0
  70. package/dist/chunk-7PCLHURF.js +101 -0
  71. package/dist/{chunk-PUVMC4PX.js → chunk-7V34ZMMS.js} +1 -1
  72. package/dist/{chunk-AEWNWAXW.js → chunk-7XJNYLQW.js} +2 -2
  73. package/dist/{chunk-WEIPY3CI.js → chunk-7ZR5CQY3.js} +1 -1
  74. package/dist/{chunk-2DYHAP4E.js → chunk-A474TUCE.js} +1 -1
  75. package/dist/chunk-A4ZV2SHL.js +5 -0
  76. package/dist/chunk-A7IMHUFY.js +27 -0
  77. package/dist/{chunk-XLEGGC4Y.js → chunk-ABMM37L2.js} +1 -1
  78. package/dist/{chunk-NIVFEACM.js → chunk-AUSLHNXQ.js} +1 -1
  79. package/dist/{chunk-YPFQ4UGF.js → chunk-B226SFOV.js} +1 -1
  80. package/dist/{chunk-DJC7NTLA.js → chunk-B57ZRHEQ.js} +1 -1
  81. package/dist/{chunk-CGITGJ3I.js → chunk-BHQIH2FE.js} +1 -1
  82. package/dist/{chunk-FWUPJORV.js → chunk-BJT6PZXL.js} +1 -1
  83. package/dist/{chunk-VX657KIK.js → chunk-C6P6YUCR.js} +1 -1
  84. package/dist/chunk-CB344EDO.js +2 -0
  85. package/dist/chunk-CCOD4GQJ.js +2 -0
  86. package/dist/{chunk-ZFM77AQU.js → chunk-CQDCNP7V.js} +1 -1
  87. package/dist/{chunk-VUFIL5VR.js → chunk-D4QXYAYA.js} +2 -2
  88. package/dist/{chunk-Y7E5L42F.js → chunk-DLP5S3TO.js} +1 -1
  89. package/dist/{chunk-35ECWCCK.js → chunk-DXIQVBMI.js} +1 -1
  90. package/dist/chunk-DXLZCJH5.js +7 -0
  91. package/dist/{chunk-OJ33Q6DU.js → chunk-E4GIGM5V.js} +1 -1
  92. package/dist/{chunk-I4WXALQR.js → chunk-EAWU2TOG.js} +1 -1
  93. package/dist/{chunk-ACMBMZDQ.js → chunk-EEOAU43D.js} +1 -1
  94. package/dist/{chunk-MYZHOBS4.js → chunk-EHB55V23.js} +1 -1
  95. package/dist/{chunk-UYDHOHSZ.js → chunk-ENRFXGID.js} +1 -1
  96. package/dist/{chunk-RTVHJ23A.js → chunk-ET5EK2CM.js} +1 -1
  97. package/dist/{chunk-EF47KRUK.js → chunk-EZMRWXRT.js} +1 -1
  98. package/dist/chunk-FAMQ4DHU.js +2 -0
  99. package/dist/{chunk-C2RUDJ46.js → chunk-FI2DVNRT.js} +1 -1
  100. package/dist/{chunk-AUJSC7PU.js → chunk-FNUGDPTS.js} +1 -1
  101. package/dist/{chunk-VLDCHFXF.js → chunk-FOLUB336.js} +1 -1
  102. package/dist/{chunk-NZ6AV2TA.js → chunk-FYPIF3BE.js} +1 -1
  103. package/dist/{chunk-HHW6MRU3.js → chunk-G4K3TP2I.js} +1 -1
  104. package/dist/{chunk-P2ZQDQDB.js → chunk-GAKBHNC4.js} +1 -1
  105. package/dist/{chunk-DPGOAFKF.js → chunk-GBQ4K25P.js} +1 -1
  106. package/dist/{chunk-O3HHTKZ5.js → chunk-GEZVC4S3.js} +1 -1
  107. package/dist/chunk-GJ7MO2FW.js +9 -0
  108. package/dist/{chunk-EZN7CF45.js → chunk-GJXO6FF7.js} +1 -1
  109. package/dist/{chunk-QDFY5GGO.js → chunk-GLM5UGTF.js} +1 -1
  110. package/dist/{chunk-HK62JVQM.js → chunk-GQARXS6F.js} +1 -1
  111. package/dist/{chunk-I4RVVBG3.js → chunk-GT3JDX5H.js} +1 -1
  112. package/dist/{chunk-YLXWAY7D.js → chunk-GZQAETB2.js} +1 -1
  113. package/dist/{chunk-7HMSMAUG.js → chunk-H4TIVILC.js} +5 -5
  114. package/dist/{chunk-VXGN3IV7.js → chunk-HG2ILWCE.js} +1 -1
  115. package/dist/{chunk-M43WH5DQ.js → chunk-HHOVANJ7.js} +1 -1
  116. package/dist/{chunk-CM4CHYSN.js → chunk-HM6LZ2KM.js} +1 -1
  117. package/dist/{chunk-QDXKEOKI.js → chunk-HNF3PWF3.js} +6 -6
  118. package/dist/{chunk-R7KXAISS.js → chunk-HVOXMCKE.js} +1 -1
  119. package/dist/{chunk-D7U2M26S.js → chunk-HWPWCCEV.js} +1 -1
  120. package/dist/{chunk-XRNQSXOM.js → chunk-HX5OLRKU.js} +2 -2
  121. package/dist/{chunk-4I7YN6YY.js → chunk-HYJVYYAZ.js} +2 -2
  122. package/dist/{chunk-CUXY6KQ2.js → chunk-I52NWH4U.js} +1 -1
  123. package/dist/{chunk-IGEAET7M.js → chunk-IB5WG5YY.js} +1 -1
  124. package/dist/{chunk-LAOTVZHV.js → chunk-IH73ZCBB.js} +1 -1
  125. package/dist/{chunk-TU7TVFBK.js → chunk-IT5JVCZN.js} +1 -1
  126. package/dist/{chunk-54XA5MZH.js → chunk-IZ66FKPC.js} +1 -1
  127. package/dist/{chunk-44B6THYK.js → chunk-JNPFEBUR.js} +1 -1
  128. package/dist/{chunk-RX6776AI.js → chunk-JTNEF5ZP.js} +1 -1
  129. package/dist/{chunk-QBYENBMB.js → chunk-JUVY6PHY.js} +1 -1
  130. package/dist/{chunk-5AKJPYUW.js → chunk-K4K2BGQC.js} +3 -3
  131. package/dist/{chunk-HJMCXSUJ.js → chunk-K75WIRI5.js} +1 -1
  132. package/dist/{chunk-FSYOTRMC.js → chunk-KKLCXRW6.js} +1 -1
  133. package/dist/{chunk-7YT4TTKL.js → chunk-KN7GZWKK.js} +1 -1
  134. package/dist/{chunk-ZTHYAHDN.js → chunk-L3BUPFAQ.js} +4 -4
  135. package/dist/{chunk-7XBNMOH4.js → chunk-LLQWEGXD.js} +1 -1
  136. package/dist/chunk-LTPOMMAB.js +2 -0
  137. package/dist/{chunk-CCP4X75B.js → chunk-LWCP4GLY.js} +1 -1
  138. package/dist/chunk-LXCTV75T.js +12 -0
  139. package/dist/{chunk-RDP7GWSY.js → chunk-LZGAFKYH.js} +1 -1
  140. package/dist/{chunk-3QICDXY5.js → chunk-LZPYIFHZ.js} +1 -1
  141. package/dist/{chunk-3OQW2GTA.js → chunk-M3TFOFUQ.js} +1 -1
  142. package/dist/{chunk-V7USCQWO.js → chunk-M7Y5GGVJ.js} +1 -1
  143. package/dist/{chunk-SMTBOSEJ.js → chunk-MEMXFTLD.js} +1 -1
  144. package/dist/{chunk-D756UWY2.js → chunk-MINDIQET.js} +1 -1
  145. package/dist/{chunk-ZTRRFG52.js → chunk-MP6NCJFE.js} +1 -1
  146. package/dist/{chunk-GXKY5A46.js → chunk-MSYRAPDK.js} +1 -1
  147. package/dist/{chunk-HJLMH7ZM.js → chunk-MUX2A37P.js} +1 -1
  148. package/dist/{chunk-YHFZFV3A.js → chunk-NCP54AIQ.js} +9 -9
  149. package/dist/{chunk-ZU4W2QGM.js → chunk-NVD2MXHQ.js} +1 -1
  150. package/dist/{chunk-FWDUVFS6.js → chunk-O2Y46A3G.js} +17 -17
  151. package/dist/{chunk-XZGEN4NU.js → chunk-O3TXAMFW.js} +1 -1
  152. package/dist/{chunk-YGRULEZY.js → chunk-O5KTMDTH.js} +1 -1
  153. package/dist/{chunk-PAWQ4AKN.js → chunk-OK6NLITG.js} +1 -1
  154. package/dist/{chunk-7AET4JKQ.js → chunk-OKA6FPJM.js} +1 -1
  155. package/dist/{chunk-3YTCKCBG.js → chunk-OVNTCBNS.js} +1 -1
  156. package/dist/{chunk-YQ5C6UDG.js → chunk-P4VFC6HO.js} +1 -1
  157. package/dist/{chunk-LQQNPMOD.js → chunk-PC22QRIY.js} +1 -1
  158. package/dist/{chunk-XQMWHPZI.js → chunk-PEUIHME2.js} +1 -1
  159. package/dist/{chunk-UEE3RZN4.js → chunk-PI7OXS62.js} +1 -1
  160. package/dist/{chunk-D7TKE7LK.js → chunk-POA336CU.js} +1 -1
  161. package/dist/{chunk-WZXPF3BI.js → chunk-PR5EGLEI.js} +1 -1
  162. package/dist/{chunk-YIKF4ERQ.js → chunk-PRBWZXFA.js} +2 -2
  163. package/dist/{chunk-XZYA7DNH.js → chunk-PVN64537.js} +1 -1
  164. package/dist/{chunk-VSVWNRI2.js → chunk-PWNYTIVA.js} +1 -1
  165. package/dist/chunk-Q4JV4U65.js +161 -0
  166. package/dist/{chunk-LUZBGTYB.js → chunk-Q5AKIQIE.js} +1 -1
  167. package/dist/{chunk-6EB5VRAN.js → chunk-QB77LRF4.js} +1 -1
  168. package/dist/{chunk-GQRU3B54.js → chunk-QUNIY6NN.js} +1 -1
  169. package/dist/{chunk-KODJVOCN.js → chunk-QVMXL675.js} +1 -1
  170. package/dist/{chunk-LCSJ7GOG.js → chunk-R6TFRAMZ.js} +1 -1
  171. package/dist/{chunk-4YW767UV.js → chunk-RAVAJZV2.js} +7 -7
  172. package/dist/{chunk-DDZLCAEO.js → chunk-RDAIOJCR.js} +1 -1
  173. package/dist/{chunk-RPRXRKKR.js → chunk-RQKMSNEU.js} +1 -1
  174. package/dist/{chunk-ECPFI75W.js → chunk-RRKYHUOD.js} +1 -1
  175. package/dist/{chunk-3RJHXOZH.js → chunk-S7XCOBYD.js} +1 -1
  176. package/dist/{chunk-Q3C6NDGI.js → chunk-SALZ6WSF.js} +1 -1
  177. package/dist/{chunk-ZFMRQ57Y.js → chunk-SIHX5FW5.js} +1 -1
  178. package/dist/{chunk-FIP5L6LV.js → chunk-SSOUYKVG.js} +1 -1
  179. package/dist/{chunk-TNORODUF.js → chunk-SVIIUKJ2.js} +1 -1
  180. package/dist/{chunk-7RWP4Y3H.js → chunk-T77LTLAD.js} +1 -1
  181. package/dist/{chunk-NLZZLANH.js → chunk-TAY7J5VS.js} +1 -1
  182. package/dist/chunk-TD6GCEIK.js +2 -0
  183. package/dist/{chunk-LKQFG4RW.js → chunk-TM6VLC6V.js} +1 -1
  184. package/dist/{chunk-YAW6JW6D.js → chunk-TMH4TPMB.js} +1 -1
  185. package/dist/{chunk-OFSDB7B4.js → chunk-TU2KPOW2.js} +2 -2
  186. package/dist/{chunk-3BSYOCSW.js → chunk-U2VYTVKV.js} +1 -1
  187. package/dist/{chunk-LIGTP3A3.js → chunk-UCVP7ZY4.js} +1 -1
  188. package/dist/{chunk-RHGW7B5Q.js → chunk-UICJ2KLJ.js} +1 -1
  189. package/dist/chunk-UJLULWSR.js +21 -0
  190. package/dist/{chunk-OCDBTAYS.js → chunk-UMNCM4RJ.js} +2 -2
  191. package/dist/{chunk-WOSANGV6.js → chunk-UWPG5MWM.js} +1 -1
  192. package/dist/{chunk-W6HZF56M.js → chunk-V3OZJO7Y.js} +1 -1
  193. package/dist/{chunk-3F5FMH76.js → chunk-VE4HLIGA.js} +1 -1
  194. package/dist/{chunk-RF37IJNN.js → chunk-W2HRX3DR.js} +1 -1
  195. package/dist/{chunk-NXRF7FFS.js → chunk-W54BX6HC.js} +1 -1
  196. package/dist/{chunk-IZ65ZPWY.js → chunk-W5HFUBXD.js} +1 -1
  197. package/dist/{chunk-HAW5WEKT.js → chunk-WEJR2V7R.js} +1 -1
  198. package/dist/{chunk-F5NHG7VB.js → chunk-X3A4QPA3.js} +1 -1
  199. package/dist/{chunk-AVI5H4UM.js → chunk-X52YIWGG.js} +1 -1
  200. package/dist/{chunk-72RC7JSA.js → chunk-X6FCXBXU.js} +1 -1
  201. package/dist/{chunk-PZA3BSOE.js → chunk-X7S7IGCV.js} +1 -1
  202. package/dist/{chunk-6DZX5HLZ.js → chunk-XCUF5AVM.js} +1 -1
  203. package/dist/{chunk-F22K3RRX.js → chunk-XHFU5TGS.js} +1 -1
  204. package/dist/chunk-XNXJXGVB.js +4 -0
  205. package/dist/{chunk-C62QWG4B.js → chunk-XZ6J3Y2W.js} +1 -1
  206. package/dist/{chunk-JGRXMTME.js → chunk-YDB72F4K.js} +1 -1
  207. package/dist/{chunk-7DFBOVUB.js → chunk-YJAQZMJT.js} +1 -1
  208. package/dist/chunk-YO6SNXBJ.js +2 -0
  209. package/dist/{chunk-AZLNLHUA.js → chunk-Z24SD2EJ.js} +1 -1
  210. package/dist/{chunk-HQ2E2XCU.js → chunk-Z36KVIRR.js} +1 -1
  211. package/dist/{chunk-WAOUE7MP.js → chunk-Z6SI7YNV.js} +1 -1
  212. package/dist/{chunk-6NFOH4AC.js → chunk-ZAQGIC33.js} +1 -1
  213. package/dist/{chunk-6UVIY56J.js → chunk-ZCL7XIVS.js} +1 -1
  214. package/dist/{chunk-UUJIGOEO.js → chunk-ZDCXWEQG.js} +1 -1
  215. package/dist/{chunk-SGPAM5DZ.js → chunk-ZDQYGLCZ.js} +1 -1
  216. package/dist/{chunk-42PALMW2.js → chunk-ZHAMVLQZ.js} +1 -1
  217. package/dist/{chunk-W7FLXW6Q.js → chunk-ZMWTRXFH.js} +1 -1
  218. package/dist/{chunk-KXHJMAZU.js → chunk-ZO3ZAMUU.js} +2 -2
  219. package/dist/{chunk-L5DALV5N.js → chunk-ZZZGTDYE.js} +1 -1
  220. package/dist/commands-R5AYK6XM.js +2 -0
  221. package/dist/{committer-JGY66PFM.js → committer-UO3B3S5Y.js} +1 -1
  222. package/dist/{config-754B73XK.js → config-YMHI3H3Y.js} +1 -1
  223. package/dist/cover-cmd-DVQIGFDY.js +2 -0
  224. package/dist/{credentials-F7DYLVWY.js → credentials-BCR73VGS.js} +1 -1
  225. package/dist/{deps-bundle-PW3WEQJ7.js → deps-bundle-6WLX44OA.js} +1 -1
  226. package/dist/{deps-resolve-SQYVN76L.js → deps-resolve-DSAKPZ3T.js} +1 -1
  227. package/dist/{design-chat-F3OEZPNJ.js → design-chat-YUI2JPO6.js} +1 -1
  228. package/dist/design-committer-7YIPFKMO.js +2 -0
  229. package/dist/design-headless-KIP6R7UV.js +2 -0
  230. package/dist/{design-remote-2BEGCVCX.js → design-remote-XMSHDDUX.js} +2 -2
  231. package/dist/device-env-K7J5NN66.js +2 -0
  232. package/dist/dispatch-BV6XMCN3.js +2 -0
  233. package/dist/{doctor-XY26Z35T.js → doctor-PGTNOMSP.js} +1 -1
  234. package/dist/{docx-convert-6IZO5P5K.js → docx-convert-DO5AQYD3.js} +1 -1
  235. package/dist/{dossier-NROC2MCY.js → dossier-5XKNAK6Q.js} +1 -1
  236. package/dist/evidence-RO3RDZXO.js +2 -0
  237. package/dist/evidence-presentation-LSFOZGLH.js +2 -0
  238. package/dist/evolve-cmd-U2ALVGMT.js +2 -0
  239. package/dist/evolve-remote-K2MCCVMM.js +2 -0
  240. package/dist/{exit-manager-EDHCETUN.js → exit-manager-EGWAZHCR.js} +1 -1
  241. package/dist/{explain-cmd-VYAANFFZ.js → explain-cmd-KNDORU2D.js} +1 -1
  242. package/dist/{explain-cmd-OP5I5W3O.js → explain-cmd-UWK5YVXG.js} +1 -1
  243. package/dist/explore-S2BGQUIF.js +2 -0
  244. package/dist/{explore-context-tty-RZ7D2TBV.js → explore-context-tty-WJHUSP3A.js} +1 -1
  245. package/dist/{explore-entry-EKXJ67BD.js → explore-entry-3EX2T3NS.js} +4 -4
  246. package/dist/{explore-live-2YVRAQZO.js → explore-live-TRY5A2ME.js} +1 -1
  247. package/dist/{explore-run-tty-D47FGPX7.js → explore-run-tty-ZV5XFKZA.js} +2 -2
  248. package/dist/{extract-bind-W2NET364.js → extract-bind-TXUBMK3T.js} +3 -3
  249. package/dist/extract-chat-VPYDGQKO.js +2 -0
  250. package/dist/{extract-cmd-FTFLETOP.js → extract-cmd-YUOYMVF5.js} +2 -2
  251. package/dist/extract-headless-UWTAPOET.js +2 -0
  252. package/dist/{feeder-NY45UFJK.js → feeder-NGWIPZ26.js} +1 -1
  253. package/dist/folder-flags-WV7UV3JG.js +2 -0
  254. package/dist/gaps-cmd-PFV3FZCM.js +3 -0
  255. package/dist/gate-7ALXLCNB.js +2 -0
  256. package/dist/gate-NB5CJMTN.js +2 -0
  257. package/dist/{generate-headless-RURIEKVS.js → generate-headless-KMBBZTLS.js} +2 -2
  258. package/dist/hold-passthrough-JGHWMYDM.js +2 -0
  259. package/dist/impact-cmd-PW33L5RF.js +11 -0
  260. package/dist/index.js +4150 -180
  261. package/dist/ingest-ZHHHBUXR.js +2 -0
  262. package/dist/{ingest-cmd-4G2AK4Y2.js → ingest-cmd-MXYILQLV.js} +3 -3
  263. package/dist/ingest-remote-2EEJP6ML.js +2 -0
  264. package/dist/install-7J34AYB6.js +2 -0
  265. package/dist/{interactive-bind-SI2ZS55Q.js → interactive-bind-FDWJUTI6.js} +4 -4
  266. package/dist/{interactive-remote-J56EWJGA.js → interactive-remote-O2Q2FNOH.js} +2 -2
  267. package/dist/lane-CNGO7LH5.js +2 -0
  268. package/dist/lattice-auth-TXNDLHM6.js +2 -0
  269. package/dist/{lifecycle-cmd-HJ37LTXE.js → lifecycle-cmd-GFHDBRXX.js} +1 -1
  270. package/dist/{list-cmd-6XL2FYLQ.js → list-cmd-RR75PMPE.js} +1 -1
  271. package/dist/list-commands-3QGZWJ5P.js +2 -0
  272. package/dist/{list-remote-LXPQNXYN.js → list-remote-AA3VSWOI.js} +1 -1
  273. package/dist/{locks-cmd-JJ2QNTNY.js → locks-cmd-AZKCSGHI.js} +1 -1
  274. package/dist/{logical-ids-RXAQJZ3T.js → logical-ids-74PLU3VR.js} +1 -1
  275. package/dist/login-flow-ZQ6UFTS2.js +2 -0
  276. package/dist/{maintenance-cmd-BXXHP36K.js → maintenance-cmd-OHGVARQ2.js} +1 -1
  277. package/dist/{mobile-prompts-CECJ5UY2.js → mobile-prompts-FZRKLLTN.js} +1 -1
  278. package/dist/{objective-variable-gate-3Z7DNVVC.js → objective-variable-gate-V5HHFOUS.js} +1 -1
  279. package/dist/{onboarding-PDVYMTY5.js → onboarding-NXGMV3VG.js} +1 -1
  280. package/dist/open-provider-XDJKT3W3.js +2 -0
  281. package/dist/pdf-convert-YB6PJFMI.js +2 -0
  282. package/dist/persist-recorded-session-INFN4JZT.js +3 -0
  283. package/dist/phase-seed-ZZSJME7M.js +2 -0
  284. package/dist/pipeline-MVZRI6YZ.js +2 -0
  285. package/dist/policy-commands-3YJ6YCDN.js +8 -0
  286. package/dist/prepare-target-DII5WZCX.js +2 -0
  287. package/dist/{pull-cmd-UPFQYUND.js → pull-cmd-XZN53XFZ.js} +1 -1
  288. package/dist/pull-route-R33BVADE.js +2 -0
  289. package/dist/readmodel-TRV4E3MW.js +2 -0
  290. package/dist/real-device-run-DGENHGUV.js +2 -0
  291. package/dist/{reconcile-cmd-JBH365JL.js → reconcile-cmd-KFPRCCJB.js} +4 -4
  292. package/dist/reconcile-deps-UDQBWSLE.js +2 -0
  293. package/dist/{reconcile-remote-BCX6SWFC.js → reconcile-remote-6WISFGRG.js} +2 -2
  294. package/dist/{recording-banner-YKBAL6UB.js → recording-banner-XOX2CDCF.js} +1 -1
  295. package/dist/registry-NV3EMDMK.js +2 -0
  296. package/dist/remote-entry-BCTFT643.js +2 -0
  297. package/dist/remote-mode-4HN27MD4.js +4 -0
  298. package/dist/{remote-words-YVB66R3F.js → remote-words-LFDYKIZ7.js} +1 -1
  299. package/dist/{require-project-folder-MLMEQJYP.js → require-project-folder-ZK4JJCDB.js} +1 -1
  300. package/dist/{resolve-run-intent-PC7TQZUL.js → resolve-run-intent-LYLVNNDZ.js} +1 -1
  301. package/dist/{resolver-EID34LQE.js → resolver-RMHGGYRP.js} +1 -1
  302. package/dist/revert-QKHPCRT6.js +2 -0
  303. package/dist/{review-cmd-EUHFLFMY.js → review-cmd-UGF2FC5Y.js} +1 -1
  304. package/dist/run-CSYGVV3D.js +2 -0
  305. package/dist/run-YUHHD54J.js +2 -0
  306. package/dist/{run-channel-63SVP5OI.js → run-channel-IIIYXOIW.js} +1 -1
  307. package/dist/run-remote-BGKQDAOA.js +2 -0
  308. package/dist/{run-startup-gate-YO66G6LS.js → run-startup-gate-4XE73OON.js} +1 -1
  309. package/dist/run-test-md-G6U3RU2Q.js +19 -0
  310. package/dist/session-worker.js +2 -2
  311. package/dist/{sessions-CFV7FOIT.js → sessions-NH2EG7BP.js} +1 -1
  312. package/dist/{sessions-cmd-S7WZBUCN.js → sessions-cmd-CABAX7BO.js} +2 -2
  313. package/dist/{sessions-remote-IWHWIQ2T.js → sessions-remote-Y4FTZL7Y.js} +1 -1
  314. package/dist/{skill-installer-MAVQY6GW.js → skill-installer-FS2AV7GX.js} +1 -1
  315. package/dist/spawner-MQ4XEHIX.js +2 -0
  316. package/dist/{store-MSA7KASS.js → store-PLKJZTGC.js} +1 -1
  317. package/dist/store-choice-UAB6Z4AL.js +2 -0
  318. package/dist/store-guard-DUN2X3SR.js +2 -0
  319. package/dist/{store-site-KA2DNBGY.js → store-site-K5NHLI7D.js} +1 -1
  320. package/dist/stream-warnings-GM7YEOVG.js +2 -0
  321. package/dist/sync-cmd-AGTOGPYM.js +2 -0
  322. package/dist/{sync-setup-RBRDUV7Q.js → sync-setup-4KIY3PDO.js} +1 -1
  323. package/dist/tcg-generate-CUY4AZ2V.js +2 -0
  324. package/dist/{test-definition-VRI4YIYL.js → test-definition-53XNBEDE.js} +1 -1
  325. package/dist/testmd-actions-UD6PAWUX.js +2 -0
  326. package/dist/{testmd-sync-UPAA5UMD.js → testmd-sync-EEJ7GPLR.js} +1 -1
  327. package/dist/tms-client-XWCR7O7J.js +2 -0
  328. package/dist/token-refresh-K6PVBBFE.js +2 -0
  329. package/dist/{trust-gate-AT2XBWN4.js → trust-gate-674C2NZS.js} +1 -1
  330. package/dist/{turn-preflight-LHYLRL7G.js → turn-preflight-R4PU6NYY.js} +1 -1
  331. package/dist/{use-case-ref-NE4X4MZN.js → use-case-ref-44BPIP4N.js} +1 -1
  332. package/dist/{validate-basic-M5JHHNZA.js → validate-basic-3JZRZL45.js} +1 -1
  333. package/dist/{variable-receipt-BXSZO36E.js → variable-receipt-7PRKDTRJ.js} +1 -1
  334. package/dist/verdicts-PVB7TV5S.js +2 -0
  335. package/dist/{version-check-Q737BE65.js → version-check-IY3YSQIP.js} +1 -1
  336. package/dist/{view-cmd-XSNL5DGI.js → view-cmd-WUIGTRFX.js} +1 -1
  337. package/dist/{walk-session-SHGYLFRB.js → walk-session-EH7227WR.js} +1 -1
  338. package/dist/with-telemetry-7JMZUBUZ.js +2 -0
  339. package/package.json +17 -17
  340. package/dist/ChatSurface-6NZGMNHL.js +0 -2
  341. package/dist/EvidenceViewOffer-WIEWCZUP.js +0 -2
  342. package/dist/FolderPicker-AF7ZMV3M.js +0 -2
  343. package/dist/InfoBox-D7GGZJU4.js +0 -2
  344. package/dist/ProjectPicker-OBYHJJLU.js +0 -2
  345. package/dist/SaveSessionPrompt-7XSHS4NL.js +0 -2
  346. package/dist/SingleShotApp-XQUDR36R.js +0 -2
  347. package/dist/TestMdRunView-LS2QUFWR.js +0 -2
  348. package/dist/TestrunEvidenceTable-HNDVJDIF.js +0 -2
  349. package/dist/bind-4XWK3DG2.js +0 -2
  350. package/dist/bootstrap-6ACT4ALI.js +0 -2
  351. package/dist/bridge-T6QMYKED.js +0 -2
  352. package/dist/chat-committer-ZCSRJEUB.js +0 -2
  353. package/dist/chat-controller-XINCDH6Z.js +0 -2
  354. package/dist/child-G2GCW73X.js +0 -2
  355. package/dist/chunk-34R7BNZ2.js +0 -2
  356. package/dist/chunk-65VANXOF.js +0 -147
  357. package/dist/chunk-C6HI6Y3S.js +0 -2
  358. package/dist/chunk-D36V5OX6.js +0 -2
  359. package/dist/chunk-HCJ2N3XB.js +0 -12
  360. package/dist/chunk-IUQOG7Z5.js +0 -5
  361. package/dist/chunk-KF4DKXSS.js +0 -2
  362. package/dist/chunk-NC7D7GOM.js +0 -21
  363. package/dist/chunk-OGFU4YY4.js +0 -2
  364. package/dist/chunk-R4JUKTDO.js +0 -2
  365. package/dist/chunk-VZ4A6WMK.js +0 -97
  366. package/dist/chunk-W54OT2FU.js +0 -9
  367. package/dist/chunk-W72ACCFL.js +0 -27
  368. package/dist/chunk-WXJCJL5L.js +0 -7
  369. package/dist/cover-cmd-NBNZCR6C.js +0 -2
  370. package/dist/design-committer-TRYP3LOZ.js +0 -2
  371. package/dist/design-headless-OTHYOX3E.js +0 -2
  372. package/dist/device-env-CHFRRV6W.js +0 -2
  373. package/dist/dispatch-DVQ3H7EJ.js +0 -2
  374. package/dist/evidence-P6FFKC7B.js +0 -2
  375. package/dist/evidence-presentation-YYTIDCBS.js +0 -2
  376. package/dist/evolve-cmd-WWOB3QJR.js +0 -2
  377. package/dist/evolve-remote-WLVY3QID.js +0 -2
  378. package/dist/explore-K5YBGHK6.js +0 -2
  379. package/dist/extract-chat-M65NWGUK.js +0 -2
  380. package/dist/extract-headless-G6W6JQ27.js +0 -2
  381. package/dist/folder-flags-KKIH654K.js +0 -2
  382. package/dist/gaps-cmd-OIDDLRYL.js +0 -3
  383. package/dist/gate-7AKRPRMK.js +0 -2
  384. package/dist/gate-WISOUTHQ.js +0 -2
  385. package/dist/hold-passthrough-IOWPVB4W.js +0 -2
  386. package/dist/ingest-PDGS5ZTL.js +0 -2
  387. package/dist/ingest-remote-SSLUHQVG.js +0 -2
  388. package/dist/install-ZVBHPXGP.js +0 -2
  389. package/dist/lane-AQYRIW24.js +0 -2
  390. package/dist/lattice-auth-6FEVSR7E.js +0 -2
  391. package/dist/list-commands-5DCCKU3L.js +0 -2
  392. package/dist/login-flow-WEK3E476.js +0 -2
  393. package/dist/open-provider-OZAG6WZS.js +0 -2
  394. package/dist/pdf-convert-447ACUB3.js +0 -2
  395. package/dist/persist-recorded-session-A3ID7JFA.js +0 -3
  396. package/dist/phase-seed-LCJ4WSYV.js +0 -2
  397. package/dist/pipeline-GX3LKPI5.js +0 -2
  398. package/dist/prepare-target-FMT6QFHZ.js +0 -2
  399. package/dist/pull-route-FWBXJMR7.js +0 -2
  400. package/dist/readmodel-INMP6MNW.js +0 -2
  401. package/dist/real-device-run-X7JJWOIK.js +0 -2
  402. package/dist/reconcile-deps-TWJ3FTSU.js +0 -2
  403. package/dist/registry-VQC757MJ.js +0 -2
  404. package/dist/remote-entry-X6JMPC2K.js +0 -2
  405. package/dist/remote-mode-FDPA7EWG.js +0 -4
  406. package/dist/revert-FHOBLZWF.js +0 -2
  407. package/dist/run-5RQUCNYP.js +0 -2
  408. package/dist/run-PC5YO4AS.js +0 -2
  409. package/dist/run-remote-SJCRTL7O.js +0 -2
  410. package/dist/run-test-md-BLNBK4MH.js +0 -17
  411. package/dist/spawner-C7NLLM4F.js +0 -2
  412. package/dist/store-choice-3OJCV26J.js +0 -2
  413. package/dist/store-guard-OOSDLMEC.js +0 -2
  414. package/dist/stream-warnings-GEQKKJU7.js +0 -2
  415. package/dist/sync-cmd-RDFDMVKQ.js +0 -2
  416. package/dist/tcg-generate-KIECTZ2C.js +0 -2
  417. package/dist/testmd-actions-CMAG6HWI.js +0 -2
  418. package/dist/tms-client-NXAB6VJD.js +0 -2
  419. package/dist/token-refresh-KP3AYMYK.js +0 -2
  420. package/dist/verdicts-XK3GAUX3.js +0 -2
  421. package/dist/with-telemetry-PM2HVN2B.js +0 -2
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as qn}from"./chunk-PAWQ4AKN.js";import{a as Fn}from"./chunk-C5Z7MQE6.js";import{a as Un}from"./chunk-LUZBGTYB.js";import"./chunk-47WQBG5I.js";import{a as Bn}from"./chunk-YDSGXB25.js";import{b as le,c as ve}from"./chunk-6UVIY56J.js";import{d as Ln}from"./chunk-FSYOTRMC.js";import"./chunk-OFSDB7B4.js";import{a as at,d as dt,e as ct,i as Fe,j as ye}from"./chunk-LKQFG4RW.js";import{a as Ee}from"./chunk-RTVWQK7I.js";import"./chunk-TNORODUF.js";import"./chunk-I6S6DZ2E.js";import{e as he,f as it}from"./chunk-YIKF4ERQ.js";import"./chunk-QI5RZ7LL.js";import{b as Mn}from"./chunk-44B6THYK.js";import{d as jn}from"./chunk-W7FLXW6Q.js";import"./chunk-KM3YCIDV.js";import{e as Re,f as Le,g as Nn,h as ce}from"./chunk-R4JUKTDO.js";import"./chunk-OJ33Q6DU.js";import{d as Tn}from"./chunk-7KX2BHKG.js";import{e as Be}from"./chunk-D756UWY2.js";import"./chunk-LX2I4JEH.js";import"./chunk-O3HHTKZ5.js";import"./chunk-NXRF7FFS.js";import{c as Pn,i as $n}from"./chunk-AVI5H4UM.js";import{a as Dn,c as In}from"./chunk-LCSJ7GOG.js";import{a as Rn,d as En}from"./chunk-HAW5WEKT.js";import"./chunk-HJLMH7ZM.js";import"./chunk-E6KSRQXL.js";import"./chunk-54XA5MZH.js";import"./chunk-QDFY5GGO.js";import{a as On}from"./chunk-VZJ6LUXX.js";import{n as An}from"./chunk-35ECWCCK.js";import"./chunk-IZ65ZPWY.js";import"./chunk-7RWP4Y3H.js";import{a as _n}from"./chunk-73ZFOJOK.js";import"./chunk-EF47KRUK.js";import"./chunk-3GXN6VF6.js";import"./chunk-Z55KBMYV.js";import"./chunk-LD5B3QFW.js";import{b as se}from"./chunk-MYVKUJGS.js";import{b as Cn,d as xn,e as ot}from"./chunk-P2ZQDQDB.js";import"./chunk-3BSYOCSW.js";import{b as bn,c as Sn}from"./chunk-HIUAUZNL.js";import{f as hn,g as vn,h as je,i as yn,j as wn}from"./chunk-457Y5TEC.js";import{a as Me,b as kn}from"./chunk-EECDDDSB.js";import"./chunk-HD6NR44L.js";import{b as gn,e as mn,f as G,g as rt}from"./chunk-7NPTL66J.js";import{b as st}from"./chunk-BWXLZS5O.js";import"./chunk-63EKRZKI.js";import"./chunk-3JLEDSG5.js";import"./chunk-42PALMW2.js";import{g as rn}from"./chunk-ZFMRQ57Y.js";import{i as sn}from"./chunk-PZA3BSOE.js";import"./chunk-2RUSXQ3O.js";import"./chunk-KF4DKXSS.js";import"./chunk-AUJSC7PU.js";import{d as tt}from"./chunk-JNSWKGTB.js";import{b as Et}from"./chunk-D7TKE7LK.js";import{b as pn,h as fn,i as nt}from"./chunk-I4RVVBG3.js";import{a as _t}from"./chunk-3QICDXY5.js";import{c as cn,h as ln,i as un}from"./chunk-UUJIGOEO.js";import{k as Te,m as dn}from"./chunk-ZTHYAHDN.js";import"./chunk-PGESS7BW.js";import"./chunk-FWGUISUG.js";import{j as on,k as an,q as et}from"./chunk-AZLNLHUA.js";import"./chunk-AQ2OG2EF.js";import"./chunk-DPGOAFKF.js";import"./chunk-4IEQNX7F.js";import"./chunk-MNBGG4H3.js";import"./chunk-VRIZDOO5.js";import"./chunk-ZHWU6L2G.js";import{l as nn}from"./chunk-REKHAN53.js";import"./chunk-GRURFGBP.js";import"./chunk-MYZHOBS4.js";import"./chunk-VLDCHFXF.js";import{a as Ze,c as Gt,d as Kt,e as Vt,g as Jt,j as Yt}from"./chunk-EZN7CF45.js";import"./chunk-7XBNMOH4.js";import"./chunk-ZCIWQHCO.js";import"./chunk-XB6BJPDL.js";import{b as Wt}from"./chunk-ZFM77AQU.js";import{b as re}from"./chunk-RF37IJNN.js";import"./chunk-XZYA7DNH.js";import{Ba as T,C as ge,Ca as ne,D as Zt,Ea as en,Fa as Xe,Ha as tn,g as Qe,ka as Qt,n as I,oa as Xt,pa as me}from"./chunk-7HMSMAUG.js";import{a as Ne,c as zt}from"./chunk-GFLB2SHW.js";import"./chunk-2TVPA3LL.js";import"./chunk-VJGWVBZR.js";import"./chunk-22PIMG52.js";import"./chunk-I2MC6VVX.js";import{b as Rt}from"./chunk-RPRXRKKR.js";import"./chunk-QXQ7KVEN.js";import"./chunk-7AET4JKQ.js";import{d as Pt,f as $t}from"./chunk-DJC7NTLA.js";import"./chunk-QSCXXNC2.js";import{$a as qt,Ea as J,La as Ft,M as $,Ma as ze,Na as Ut,Qa as fe,R as Ye,S as Lt,a as Je,db as Ht,i as Nt,kb as $e,l as Tt,mb as _e,o as jt,oa as Bt,u as Pe}from"./chunk-UEE3RZN4.js";import"./chunk-DBMW3VUN.js";import{f as Ae}from"./chunk-KU3YHPWZ.js";import{e as Mt}from"./chunk-6NFOH4AC.js";import"./chunk-PUVMC4PX.js";import"./chunk-B7ZX5HEN.js";import"./chunk-VZ7KXRXB.js";import"./chunk-7V4BQSSV.js";import"./chunk-VO66KP2W.js";import{b as xe,g as Dt,i as Ve,j as It,k as Ot,p as At}from"./chunk-HHW6MRU3.js";import"./chunk-7DFBOVUB.js";import{b as xt}from"./chunk-4I7YN6YY.js";import"./chunk-6PIIUAZF.js";import"./chunk-GMTHZUZ3.js";import"./chunk-NC7D7GOM.js";import"./chunk-ZCRZFAOT.js";import"./chunk-C2RUDJ46.js";import"./chunk-4QTH7VYE.js";import"./chunk-RZ4F3BHX.js";import"./chunk-A7RJQJNT.js";import"./chunk-HJMCXSUJ.js";import"./chunk-D36V5OX6.js";import"./chunk-UR6MHSHU.js";import{parentPort as ks,workerData as Ss}from"worker_threads";function Ue(e){let t=new Set(e.call(I.children,null));return{has:n=>t.has(n),register(n,r){e.call(I.registerChild,{childId:n,...r?{useCase:r}:{}}),t.add(n)},ids:()=>[...t]}}function oe(e,t){return t===e?{}:{childId:t}}import{existsSync as rs,mkdirSync as tr,writeFileSync as ss}from"fs";import{join as nr}from"path";var ue=e=>({hash:e}),ie=e=>e.hash,Vr=4;function Jr(e,t,n,r,i){let s=a=>`${a.seq} after ${String(a.prev_hash)}`;if(e.record.seq!==r||e.record.prev_hash!==i)throw new J(`the record the sink answered with is at ${s(e.record)}, not at ${s(t)}`);ze(e.record,`stored record ${r}`);let o=fe(e.record);if(o!==e.hash)throw new J(`the sink answered record ${r} with hash ${e.hash}, but the record hashes to ${o}`);if(!e.replayed&&o!==n)throw new J(`the sink stored record ${r} other than the one handed to it, without a replayed attempt`);return{record:e.record,hash:o}}function Hn(e){let t=e.index(e.base);if(t.applied.hash!==e.base)throw new J(`the index handed in is at ${String(t.applied.hash)}, not at the base ${String(e.base)}`);let n=t.applied.seq,r=new Set(Object.keys(t.nodeLabel)),i=[],s=[],o=new Map(e.base===null?[]:[[e.base,n]]),a=new Map,c=new Map,u=new Map,g=h=>{for(let y of h.nodes)!r.has(y.cid)&&!a.has(y.cid)&&a.set(y.cid,{label:y.label,content:y.content})},f=(h,y)=>{i.push(h),s.push(y),o.set(y,h.seq),g(h)},p=e.base;for(let h of e.drafts??[]){ze(h.record,`draft ${h.record.seq}`);let y=fe(h.record);if(h.record.prev_hash!==p||h.record.seq!==n+i.length+1)throw new J(`draft ${h.record.seq} does not follow ${String(p)} at position ${n+i.length}`);f(h.record,y),h.envelope&&u.set(y,h.envelope),h.attempt&&c.set(h.attempt.id,{intentDigest:h.attempt.intentDigest,result:{token:ue(y),record:h.record}}),p=y}let l=t,m=()=>{let h=l??e.index(e.base);return l=null,h},_=h=>{let y=m();return h>0&&_e(null,y,i.slice(0,h),s.slice(0,h),{writeNodeFiles:!1}),Ze(y)},w=null,S=()=>w??=_(i.length);S();let R=()=>{if(!e.history)throw new J("this store holds no history before its base");return e.history},d=h=>{let y=e.history?.positionOf(h)??null;return y!==null&&y<n?y:null},v=h=>{let y=R().positionOf(h);if(y===null||y>=n)throw new J(`store token ${h} is not in this store's history`);return y},k=new Map,x=h=>{if(h.token===null)return S();let y=ie(h.token);if(y===S().index.applied.hash)return S();let E=k.get(y);if(E)return k.delete(y),k.set(y,E),E;let N=o.get(y),M;if(N!==void 0)M=_(N-n);else{v(y);let L=e.index(y);if(L.applied.hash!==y)throw new J(`store token ${y} is not in this store's history`);M=Ze(L)}return k.set(y,M),k.size>Vr&&k.delete(k.keys().next().value),M},P=h=>{let y=a.get(h)??e.nodeBody(h);if(y===null)throw new J(`node body missing for ${h}`);return y},K=()=>S().index.applied.hash,F=e.vectors??Yt(),C=(h,y)=>{Nt(S().index,h),qt(h,y.intent);let E=Ft(y.intent);if(y.eventId!==void 0){let B=c.get(y.eventId);if(B){if(B.intentDigest!==E)throw new J(`append refused: attempt ${y.eventId} was made by another intent; nothing was written`);return B.result}}let N=y.basis===null?null:ie(y.basis),M=K();if(N!==M)throw new Ut(`concurrent append detected: validated against ${String(N)} but the chain head is ${String(M)} \u2014 re-open and retry`);let L=S().index.applied.seq+1,q=Ht(h,L,M,{intent:y.intent,...y.provenance?{provenance:y.provenance}:{}}),ee=fe(q);if(y.provenance)try{jt(structuredClone(S().index),q,ee)}catch(B){throw B instanceof Tt?new J(`replayed record would not pass this store's checks: ${B.message}; nothing was written`):B}let Se=e.sink({record:q,hash:ee,intent:y.intent,attemptId:y.eventId??null}),W=Jr(Se,q,ee,L,M),Q={token:ue(W.hash),record:W.record};f(W.record,W.hash),u.set(W.hash,Pe(y.intent,{seq:W.record.seq,hash:W.hash,ts:W.record.ts})),y.eventId!==void 0&&c.set(y.eventId,{intentDigest:E,result:Q});try{let B=S();_e(null,B.index,[W.record],[W.hash],{writeNodeFiles:!1}),Gt(B,W.record)}catch(B){w=null;let V=B instanceof Error?B.message:String(B);return{...Q,warnings:[`committed, but the index refresh failed (${V}): read state rebuilds on the next read`]}}return Q};return{...Kt(x,P),prefetch:h=>e.prefetch?.(h),append:C,head:()=>{let h=K();return h===null?null:ue(h)},resolveToken:h=>{let y=ie(h),E=o.get(y)??d(y);return E===null?null:{seq:E,hash:y}},tokenAt:h=>{if(h>n){let E=s[h-n-1];return E===void 0?null:ue(E)}if(h===n&&e.base!==null)return ue(e.base);let y=e.history?.tokenAt(h)??null;return y===null?null:ue(y)},intentOf:h=>u.get(ie(h))??null,serialize:h=>h===null?null:ie(h),parse:h=>h===null?null:ue(h),sameToken:(h,y)=>h===null||y===null?h===y:ie(h)===ie(y),recordsSince:h=>{let y=h===null?null:ie(h),E=y===null?0:o.get(y);return E!==void 0&&(E>n||E===n&&y===e.base)?i.slice(E-n):(y!==null&&v(y),[...R().recordsAfter(y),...i])},getBlob:h=>e.sides.getBlob(h),putBlob:h=>e.sides.putBlob(h),blobPath:h=>e.sides.blobPath(h),logFile:h=>e.sides.logFile(h),designFiles:()=>e.sides.designFiles(),vectors:()=>F,parkedFacts:()=>e.sides.parkedFacts(),proposals:()=>e.sides.proposals(),signals:()=>e.sides.signals(),sessions:()=>e.sides.sessions(),locks:(h,y)=>e.sides.locks(h,y),exists:()=>!0,ensure:()=>({created:!1}),dirOrThrow:()=>{throw new J("the store over an in-memory index keeps no directory")}}}var De=500,Yr=2e4;function zr(e,t){let{json:n}=e.call(I.mainHistory,null),r=JSON.parse(n).items,i=[],s=[];if(r.forEach((o,a)=>{let c=o.record,u=`main's record at position ${o.position}`;if(o.position!==a+1)throw new Error(`${u} came where position ${a+1} belongs; Lattice's main records are out of order`);if(fe(c)!==o.hash)throw new Error(`${u} does not hash to ${o.hash}, the hash Lattice gave for it`);if(c.prev_hash!==(s[a-1]??null))throw new Error(`${u} does not follow the record before it`);i.push(c),s.push(o.hash)}),i.length!==t.basePosition||(s.at(-1)??null)!==t.baseHash)throw new Error(`main's records end at position ${i.length} (${s.at(-1)??"empty"}), not at the session's base ${t.basePosition} (${t.baseHash??"empty"})`);return{records:i,hashes:s}}function Wn(e,t){let n=$e();return _e(null,n,e.records.slice(0,t),e.hashes.slice(0,t),{writeNodeFiles:!1}),n}function Gn(e,t,n){let r=zr(e,t);return n(`main at the session's base (position ${t.basePosition}): its read model is rebuilt from main's history (${r.records.length} records); node bodies read per key`),Zr(e,t,Wn(r,t.basePosition),r)}function Zr(e,t,n,r){let i=null,s=()=>i??=new Map(r.hashes.map((o,a)=>[o,a+1]));return{baseIndex:n,indexAt:o=>Wn(r,o),...Qr(e,t,n),history:{recordsAfter:o=>r.records.slice(o===null?0:s().get(o)??r.records.length),positionOf:o=>s().get(o)??null,tokenAt:o=>r.hashes[o-1]??null}}}function Qr(e,t,n){let r=new Map,i=[],s=null,o=f=>n.nodeLabel[f],a=(f,p)=>{r.set(f,p),r.size>Yr&&r.delete(r.keys().next().value)},c=f=>{let{nodes:p}=e.call(I.mainNodes,{position:t.basePosition,cids:f});for(let l of f){let m=p[l]??null;if(m===null)throw new Error(`Lattice answered no body for node ${l}, which main's index at position ${t.basePosition} holds`);if(m.label!==o(l))throw new Error(`Lattice answered node ${l} as a ${m.label}, but main's index holds it as a ${o(l)}`);if(Je(m.label,m.content)!==l)throw new Error(`Lattice answered node ${l} with a body whose key is ${Je(m.label,m.content)}`);a(l,m)}},u=f=>{for(let l of i.splice(0))c(l);let p=f.filter(l=>!r.has(l));for(let l=0;l<p.length;l+=De)c(p.slice(l,l+De))},g=f=>[...new Set(f)].filter(p=>o(p)!==void 0&&!r.has(p));return{nodeBody(f){let p=o(f);if(p===void 0)return null;if(!r.has(f))for(let l of i.splice(0))c(l);if(!r.has(f)){if(s===null){s=new Map;for(let[_,w]of Object.entries(n.nodeLabel)){if(_ in n.superseded)continue;let S=s.get(w);S?S.push(_):s.set(w,[_])}}let l=s.get(p)??[],m=l.indexOf(f);u([f,...g([...l.slice(m+1),...l.slice(0,m)]).slice(0,De-1)])}return r.get(f)??null},prefetch:f=>u(g(f.nodes)),readAhead(f){let p=g(f);for(let l=0;l<p.length;l+=De){let m=p.slice(l,l+De);e.call(I.mainNodesAhead,{position:t.basePosition,cids:m}),i.push(m)}}}}function Kn(e){let t=/^delta-([1-9][0-9]*)\.json$/.exec(e)?.[1];return t===void 0?null:Number(t)}function Xr(e,t,n){let r=Kn(e);if(r===null)return[];let i=r>(n??0);return t.filter(s=>{let o=/^side-([1-9][0-9]*)\.json$/.exec(s)?.[1];return o===void 0||Number(o)>r?!1:i?Number(o)>(n??0):Number(o)!==n})}function Vn(e,t,n){return r=>{if(r!==t&&!n.has(r))throw new Error(`this host keeps the checkpoint chains of session ${t} and its registered children; ${r} is neither`);let i=oe(t,r),s=()=>e.call(I.chainList,i);return{read:o=>e.call(I.chainRead,{name:o,...i}),list:()=>s().names,write:(o,a)=>{e.call(I.chainWrite,{name:o,text:a,...i})},writeIfAbsent:(o,a)=>e.call(I.chainWriteIfAbsent,{name:o,text:a,...i}),remove:o=>{if(e.call(I.chainRemove,{name:o,...i}),Kn(o)===null)return;let a=e.call(I.pointer,i),c=typeof a?.seq=="number"?a.seq:null;for(let u of Xr(o,s().names,c))e.call(I.chainRemove,{name:u,...i})},bytes:()=>s().bytes}}}function Jn(e){return{read:t=>e.call(I.filesRead,{name:t}),list:t=>e.call(I.filesList,{folder:t}),write:(t,n)=>{let r=e.call(I.filesWrite,{name:t,text:n});r.written||Mt(`the rationale design/${t} was kept as first written, so this design's rationale was not stored: ${r.message}`)},where:t=>`design/${t}`}}function zn(e,t){let{sessionId:n,children:r}=t,i=p=>p===n||r.has(p),s=new Set,o=p=>{if(!i(p))throw new xe("SESSION_MISSING",`this host keeps session ${n} and its registered children, not ${p}`)},a=p=>e.call(I.stateGet,oe(n,p)),c=p=>{let l=a(p);return l===null||Yn(l)||p===n&&!s.has(p)&&u(l,p)?null:l},u=(p,l)=>An(p,e.call(I.chainRead,{name:"base.json",...oe(n,l)})!==null),g=(p,l)=>{e.call(I.statePut,{state:l,...oe(n,p)})},f=p=>({write(l,m){if(m==="state")return g(p,l);e.call(I.acknowledge,{pointer:l.checkpoint,side:t.side.snapshot(),...t.coverage(),state:l,...oe(n,p)})},complete(l){s.delete(p);let m=a(p);m!==null&&g(p,{...m,completed_at:t.now().toISOString(),ended:l})},release(){s.delete(p)}});return{expires:!1,create(p){if(!Dt.test(p.sid))throw new xe("SESSION_MISSING",`bad sid ${JSON.stringify(p.sid)}`);o(p.sid);let l=a(p.sid);if(l!==null&&(p.sid!==n||Yn(l)||s.has(p.sid)||!u(l,p.sid)))throw new xe("SESSION_LOCKED",`${p.sid} already exists \u2014 resume it`);let m=It(p);return g(p.sid,m),s.add(p.sid),Ve(m,f(p.sid))},resume(p){o(p);let l=c(p);if(l===null)throw new xe("SESSION_MISSING",`no session ${p}`);let m=Ot(l,t.now(),{expires:!1});return g(p,m),s.add(p),Ve(m,f(p))},peek:p=>i(p)?c(p):null,list(){let p=[n,...r.ids()].map(l=>({sid:l,state:c(l)}));return At(p.filter(l=>l.state!==null))},...Vt(t.chain,p=>(o(p),es(e.call(I.pointer,oe(n,p))))),appliedEvents:p=>t.sessionRecords(p).flatMap(l=>l.event_ids??[]),recordCount:(p,l)=>t.sessionRecords(p).filter(m=>m.seq<=l).length,isLive:p=>p===n||s.has(p),tidy:()=>{}}}function Yn(e){return typeof e?.completed_at=="string"}function es(e){let t=e;return typeof t=="object"&&t!==null&&Number.isInteger(t.seq)&&Number.isInteger(t.turn_id)&&typeof t.at=="string"&&typeof t.ts=="string"&&(t.full_seq===null||Number.isInteger(t.full_seq))?t:null}var Zn=500;function ts(e){let t=Buffer.alloc(e.length*4);return e.forEach((n,r)=>t.writeFloatLE(n,r*4)),t.toString("base64")}function ns(e){let t=Buffer.from(e,"base64"),n=new Float32Array(Math.floor(t.byteLength/4));for(let r=0;r<n.length;r++)n[r]=t.readFloatLE(r*4);return n}function Qn(e,t){let n=(c,u,g)=>`${c}
2
+ import{a as qn}from"./chunk-OK6NLITG.js";import"./chunk-47WQBG5I.js";import{d as Ln}from"./chunk-KKLCXRW6.js";import"./chunk-TU2KPOW2.js";import{a as Fn}from"./chunk-C5Z7MQE6.js";import{a as Un}from"./chunk-Q5AKIQIE.js";import"./chunk-KM3YCIDV.js";import{a as Bn}from"./chunk-YDSGXB25.js";import{a as at,d as dt,e as ct,i as Fe,j as ye}from"./chunk-TM6VLC6V.js";import{b as le,c as ve}from"./chunk-ZCL7XIVS.js";import{a as Ee}from"./chunk-RTVWQK7I.js";import{e as he,f as it}from"./chunk-PRBWZXFA.js";import"./chunk-QI5RZ7LL.js";import{d as Tn}from"./chunk-4KCYNP2K.js";import"./chunk-W54BX6HC.js";import{b as Mn}from"./chunk-JNPFEBUR.js";import{d as jn}from"./chunk-ZMWTRXFH.js";import{e as Be}from"./chunk-MINDIQET.js";import"./chunk-LX2I4JEH.js";import"./chunk-GEZVC4S3.js";import"./chunk-SVIIUKJ2.js";import"./chunk-I6S6DZ2E.js";import{c as Pn,i as $n}from"./chunk-X52YIWGG.js";import{a as Dn,c as In}from"./chunk-R6TFRAMZ.js";import{a as Rn,d as En}from"./chunk-WEJR2V7R.js";import"./chunk-5F5IVART.js";import"./chunk-IZ66FKPC.js";import"./chunk-GLM5UGTF.js";import{a as On}from"./chunk-VZJ6LUXX.js";import{n as An}from"./chunk-DXIQVBMI.js";import"./chunk-MUX2A37P.js";import"./chunk-W5HFUBXD.js";import{b as se}from"./chunk-35BG2EMW.js";import{e as Re,f as Le,g as Nn,h as ce}from"./chunk-LTPOMMAB.js";import"./chunk-E4GIGM5V.js";import{b as Cn,d as xn,e as ot}from"./chunk-GAKBHNC4.js";import"./chunk-U2VYTVKV.js";import"./chunk-HD6NR44L.js";import{b as st}from"./chunk-BWXLZS5O.js";import"./chunk-63EKRZKI.js";import"./chunk-3JLEDSG5.js";import"./chunk-T77LTLAD.js";import{a as _n}from"./chunk-73ZFOJOK.js";import"./chunk-EZMRWXRT.js";import"./chunk-3KY7HHQU.js";import"./chunk-Z55KBMYV.js";import"./chunk-LD5B3QFW.js";import{d as tt}from"./chunk-32HED7X2.js";import{b as bn,c as Sn}from"./chunk-HIUAUZNL.js";import{f as hn,g as vn,h as je,i as yn,j as wn}from"./chunk-3YIA3DSL.js";import{a as Me,b as kn}from"./chunk-2COXO5LQ.js";import{b as gn,e as mn,f as G,g as rt}from"./chunk-3V4J65GN.js";import"./chunk-ZHAMVLQZ.js";import{g as rn}from"./chunk-SIHX5FW5.js";import{i as sn}from"./chunk-X7S7IGCV.js";import"./chunk-2RUSXQ3O.js";import"./chunk-CB344EDO.js";import"./chunk-FNUGDPTS.js";import{b as Et}from"./chunk-POA336CU.js";import{b as pn,h as fn,i as nt}from"./chunk-GT3JDX5H.js";import{c as cn,h as ln,i as un}from"./chunk-ZDCXWEQG.js";import{a as _t}from"./chunk-LZPYIFHZ.js";import{k as Te,m as dn}from"./chunk-L3BUPFAQ.js";import"./chunk-GBQ4K25P.js";import"./chunk-PGESS7BW.js";import"./chunk-FWGUISUG.js";import{j as on,k as an,q as et}from"./chunk-Z24SD2EJ.js";import"./chunk-AQ2OG2EF.js";import"./chunk-32MFECUA.js";import"./chunk-4IEQNX7F.js";import"./chunk-23DKB2MT.js";import"./chunk-VRIZDOO5.js";import"./chunk-ZHWU6L2G.js";import{l as nn}from"./chunk-REKHAN53.js";import"./chunk-FOLUB336.js";import{a as Ze,c as Gt,d as Kt,e as Vt,g as Jt,j as Yt}from"./chunk-GJXO6FF7.js";import"./chunk-LLQWEGXD.js";import"./chunk-ZCIWQHCO.js";import"./chunk-XB6BJPDL.js";import{b as Wt}from"./chunk-CQDCNP7V.js";import"./chunk-EHB55V23.js";import"./chunk-TD6GCEIK.js";import"./chunk-7V34ZMMS.js";import"./chunk-B7ZX5HEN.js";import{b as re}from"./chunk-W2HRX3DR.js";import"./chunk-PVN64537.js";import{Ba as T,C as ge,Ca as ne,D as Zt,Ea as en,Fa as Xe,Ha as tn,g as Qe,ka as Qt,n as I,oa as Xt,pa as me}from"./chunk-H4TIVILC.js";import{a as Ne,c as zt}from"./chunk-GFLB2SHW.js";import"./chunk-2TVPA3LL.js";import"./chunk-VJGWVBZR.js";import"./chunk-22PIMG52.js";import{b as Rt}from"./chunk-RQKMSNEU.js";import"./chunk-4C7WVQOD.js";import"./chunk-QXQ7KVEN.js";import"./chunk-OKA6FPJM.js";import{d as Pt,f as $t}from"./chunk-B57ZRHEQ.js";import"./chunk-QSCXXNC2.js";import"./chunk-6PIIUAZF.js";import{$a as qt,Ea as J,La as Ft,M as $,Ma as ze,Na as Ut,Qa as fe,R as Ye,S as Lt,a as Je,db as Ht,i as Nt,kb as $e,l as Tt,mb as _e,o as jt,oa as Bt,u as Pe}from"./chunk-PI7OXS62.js";import"./chunk-DBMW3VUN.js";import{f as Ae}from"./chunk-KU3YHPWZ.js";import"./chunk-7V4BQSSV.js";import{e as Mt}from"./chunk-ZAQGIC33.js";import"./chunk-VO66KP2W.js";import{b as xe,g as Dt,i as Ve,j as It,k as Ot,p as At}from"./chunk-G4K3TP2I.js";import"./chunk-YJAQZMJT.js";import{b as xt}from"./chunk-HYJVYYAZ.js";import"./chunk-VZ7KXRXB.js";import"./chunk-GMTHZUZ3.js";import"./chunk-UJLULWSR.js";import"./chunk-ZCRZFAOT.js";import"./chunk-FI2DVNRT.js";import"./chunk-4QTH7VYE.js";import"./chunk-RZ4F3BHX.js";import"./chunk-A7RJQJNT.js";import"./chunk-K75WIRI5.js";import"./chunk-FAMQ4DHU.js";import"./chunk-UR6MHSHU.js";import{parentPort as ks,workerData as Ss}from"worker_threads";function Ue(e){let t=new Set(e.call(I.children,null));return{has:n=>t.has(n),register(n,r){e.call(I.registerChild,{childId:n,...r?{useCase:r}:{}}),t.add(n)},ids:()=>[...t]}}function oe(e,t){return t===e?{}:{childId:t}}import{existsSync as rs,mkdirSync as tr,writeFileSync as ss}from"fs";import{join as nr}from"path";var ue=e=>({hash:e}),ie=e=>e.hash,Vr=4;function Jr(e,t,n,r,i){let s=a=>`${a.seq} after ${String(a.prev_hash)}`;if(e.record.seq!==r||e.record.prev_hash!==i)throw new J(`the record the sink answered with is at ${s(e.record)}, not at ${s(t)}`);ze(e.record,`stored record ${r}`);let o=fe(e.record);if(o!==e.hash)throw new J(`the sink answered record ${r} with hash ${e.hash}, but the record hashes to ${o}`);if(!e.replayed&&o!==n)throw new J(`the sink stored record ${r} other than the one handed to it, without a replayed attempt`);return{record:e.record,hash:o}}function Hn(e){let t=e.index(e.base);if(t.applied.hash!==e.base)throw new J(`the index handed in is at ${String(t.applied.hash)}, not at the base ${String(e.base)}`);let n=t.applied.seq,r=new Set(Object.keys(t.nodeLabel)),i=[],s=[],o=new Map(e.base===null?[]:[[e.base,n]]),a=new Map,c=new Map,u=new Map,g=h=>{for(let y of h.nodes)!r.has(y.cid)&&!a.has(y.cid)&&a.set(y.cid,{label:y.label,content:y.content})},f=(h,y)=>{i.push(h),s.push(y),o.set(y,h.seq),g(h)},p=e.base;for(let h of e.drafts??[]){ze(h.record,`draft ${h.record.seq}`);let y=fe(h.record);if(h.record.prev_hash!==p||h.record.seq!==n+i.length+1)throw new J(`draft ${h.record.seq} does not follow ${String(p)} at position ${n+i.length}`);f(h.record,y),h.envelope&&u.set(y,h.envelope),h.attempt&&c.set(h.attempt.id,{intentDigest:h.attempt.intentDigest,result:{token:ue(y),record:h.record}}),p=y}let l=t,m=()=>{let h=l??e.index(e.base);return l=null,h},_=h=>{let y=m();return h>0&&_e(null,y,i.slice(0,h),s.slice(0,h),{writeNodeFiles:!1}),Ze(y)},w=null,S=()=>w??=_(i.length);S();let R=()=>{if(!e.history)throw new J("this store holds no history before its base");return e.history},d=h=>{let y=e.history?.positionOf(h)??null;return y!==null&&y<n?y:null},v=h=>{let y=R().positionOf(h);if(y===null||y>=n)throw new J(`store token ${h} is not in this store's history`);return y},k=new Map,x=h=>{if(h.token===null)return S();let y=ie(h.token);if(y===S().index.applied.hash)return S();let E=k.get(y);if(E)return k.delete(y),k.set(y,E),E;let N=o.get(y),M;if(N!==void 0)M=_(N-n);else{v(y);let L=e.index(y);if(L.applied.hash!==y)throw new J(`store token ${y} is not in this store's history`);M=Ze(L)}return k.set(y,M),k.size>Vr&&k.delete(k.keys().next().value),M},P=h=>{let y=a.get(h)??e.nodeBody(h);if(y===null)throw new J(`node body missing for ${h}`);return y},K=()=>S().index.applied.hash,F=e.vectors??Yt(),C=(h,y)=>{Nt(S().index,h),qt(h,y.intent);let E=Ft(y.intent);if(y.eventId!==void 0){let B=c.get(y.eventId);if(B){if(B.intentDigest!==E)throw new J(`append refused: attempt ${y.eventId} was made by another intent; nothing was written`);return B.result}}let N=y.basis===null?null:ie(y.basis),M=K();if(N!==M)throw new Ut(`concurrent append detected: validated against ${String(N)} but the chain head is ${String(M)} \u2014 re-open and retry`);let L=S().index.applied.seq+1,q=Ht(h,L,M,{intent:y.intent,...y.provenance?{provenance:y.provenance}:{}}),ee=fe(q);if(y.provenance)try{jt(structuredClone(S().index),q,ee)}catch(B){throw B instanceof Tt?new J(`replayed record would not pass this store's checks: ${B.message}; nothing was written`):B}let Se=e.sink({record:q,hash:ee,intent:y.intent,attemptId:y.eventId??null}),W=Jr(Se,q,ee,L,M),Q={token:ue(W.hash),record:W.record};f(W.record,W.hash),u.set(W.hash,Pe(y.intent,{seq:W.record.seq,hash:W.hash,ts:W.record.ts})),y.eventId!==void 0&&c.set(y.eventId,{intentDigest:E,result:Q});try{let B=S();_e(null,B.index,[W.record],[W.hash],{writeNodeFiles:!1}),Gt(B,W.record)}catch(B){w=null;let V=B instanceof Error?B.message:String(B);return{...Q,warnings:[`committed, but the index refresh failed (${V}): read state rebuilds on the next read`]}}return Q};return{...Kt(x,P),prefetch:h=>e.prefetch?.(h),append:C,head:()=>{let h=K();return h===null?null:ue(h)},resolveToken:h=>{let y=ie(h),E=o.get(y)??d(y);return E===null?null:{seq:E,hash:y}},tokenAt:h=>{if(h>n){let E=s[h-n-1];return E===void 0?null:ue(E)}if(h===n&&e.base!==null)return ue(e.base);let y=e.history?.tokenAt(h)??null;return y===null?null:ue(y)},intentOf:h=>u.get(ie(h))??null,serialize:h=>h===null?null:ie(h),parse:h=>h===null?null:ue(h),sameToken:(h,y)=>h===null||y===null?h===y:ie(h)===ie(y),recordsSince:h=>{let y=h===null?null:ie(h),E=y===null?0:o.get(y);return E!==void 0&&(E>n||E===n&&y===e.base)?i.slice(E-n):(y!==null&&v(y),[...R().recordsAfter(y),...i])},getBlob:h=>e.sides.getBlob(h),putBlob:h=>e.sides.putBlob(h),blobPath:h=>e.sides.blobPath(h),logFile:h=>e.sides.logFile(h),designFiles:()=>e.sides.designFiles(),vectors:()=>F,parkedFacts:()=>e.sides.parkedFacts(),proposals:()=>e.sides.proposals(),signals:()=>e.sides.signals(),sessions:()=>e.sides.sessions(),locks:(h,y)=>e.sides.locks(h,y),exists:()=>!0,ensure:()=>({created:!1}),dirOrThrow:()=>{throw new J("the store over an in-memory index keeps no directory")}}}var De=500,Yr=2e4;function zr(e,t){let{json:n}=e.call(I.mainHistory,null),r=JSON.parse(n).items,i=[],s=[];if(r.forEach((o,a)=>{let c=o.record,u=`main's record at position ${o.position}`;if(o.position!==a+1)throw new Error(`${u} came where position ${a+1} belongs; Lattice's main records are out of order`);if(fe(c)!==o.hash)throw new Error(`${u} does not hash to ${o.hash}, the hash Lattice gave for it`);if(c.prev_hash!==(s[a-1]??null))throw new Error(`${u} does not follow the record before it`);i.push(c),s.push(o.hash)}),i.length!==t.basePosition||(s.at(-1)??null)!==t.baseHash)throw new Error(`main's records end at position ${i.length} (${s.at(-1)??"empty"}), not at the session's base ${t.basePosition} (${t.baseHash??"empty"})`);return{records:i,hashes:s}}function Wn(e,t){let n=$e();return _e(null,n,e.records.slice(0,t),e.hashes.slice(0,t),{writeNodeFiles:!1}),n}function Gn(e,t,n){let r=zr(e,t);return n(`main at the session's base (position ${t.basePosition}): its read model is rebuilt from main's history (${r.records.length} records); node bodies read per key`),Zr(e,t,Wn(r,t.basePosition),r)}function Zr(e,t,n,r){let i=null,s=()=>i??=new Map(r.hashes.map((o,a)=>[o,a+1]));return{baseIndex:n,indexAt:o=>Wn(r,o),...Qr(e,t,n),history:{recordsAfter:o=>r.records.slice(o===null?0:s().get(o)??r.records.length),positionOf:o=>s().get(o)??null,tokenAt:o=>r.hashes[o-1]??null}}}function Qr(e,t,n){let r=new Map,i=[],s=null,o=f=>n.nodeLabel[f],a=(f,p)=>{r.set(f,p),r.size>Yr&&r.delete(r.keys().next().value)},c=f=>{let{nodes:p}=e.call(I.mainNodes,{position:t.basePosition,cids:f});for(let l of f){let m=p[l]??null;if(m===null)throw new Error(`Lattice answered no body for node ${l}, which main's index at position ${t.basePosition} holds`);if(m.label!==o(l))throw new Error(`Lattice answered node ${l} as a ${m.label}, but main's index holds it as a ${o(l)}`);if(Je(m.label,m.content)!==l)throw new Error(`Lattice answered node ${l} with a body whose key is ${Je(m.label,m.content)}`);a(l,m)}},u=f=>{for(let l of i.splice(0))c(l);let p=f.filter(l=>!r.has(l));for(let l=0;l<p.length;l+=De)c(p.slice(l,l+De))},g=f=>[...new Set(f)].filter(p=>o(p)!==void 0&&!r.has(p));return{nodeBody(f){let p=o(f);if(p===void 0)return null;if(!r.has(f))for(let l of i.splice(0))c(l);if(!r.has(f)){if(s===null){s=new Map;for(let[_,w]of Object.entries(n.nodeLabel)){if(_ in n.superseded)continue;let S=s.get(w);S?S.push(_):s.set(w,[_])}}let l=s.get(p)??[],m=l.indexOf(f);u([f,...g([...l.slice(m+1),...l.slice(0,m)]).slice(0,De-1)])}return r.get(f)??null},prefetch:f=>u(g(f.nodes)),readAhead(f){let p=g(f);for(let l=0;l<p.length;l+=De){let m=p.slice(l,l+De);e.call(I.mainNodesAhead,{position:t.basePosition,cids:m}),i.push(m)}}}}function Kn(e){let t=/^delta-([1-9][0-9]*)\.json$/.exec(e)?.[1];return t===void 0?null:Number(t)}function Xr(e,t,n){let r=Kn(e);if(r===null)return[];let i=r>(n??0);return t.filter(s=>{let o=/^side-([1-9][0-9]*)\.json$/.exec(s)?.[1];return o===void 0||Number(o)>r?!1:i?Number(o)>(n??0):Number(o)!==n})}function Vn(e,t,n){return r=>{if(r!==t&&!n.has(r))throw new Error(`this host keeps the checkpoint chains of session ${t} and its registered children; ${r} is neither`);let i=oe(t,r),s=()=>e.call(I.chainList,i);return{read:o=>e.call(I.chainRead,{name:o,...i}),list:()=>s().names,write:(o,a)=>{e.call(I.chainWrite,{name:o,text:a,...i})},writeIfAbsent:(o,a)=>e.call(I.chainWriteIfAbsent,{name:o,text:a,...i}),remove:o=>{if(e.call(I.chainRemove,{name:o,...i}),Kn(o)===null)return;let a=e.call(I.pointer,i),c=typeof a?.seq=="number"?a.seq:null;for(let u of Xr(o,s().names,c))e.call(I.chainRemove,{name:u,...i})},bytes:()=>s().bytes}}}function Jn(e){return{read:t=>e.call(I.filesRead,{name:t}),list:t=>e.call(I.filesList,{folder:t}),write:(t,n)=>{let r=e.call(I.filesWrite,{name:t,text:n});r.written||Mt(`the rationale design/${t} was kept as first written, so this design's rationale was not stored: ${r.message}`)},where:t=>`design/${t}`}}function zn(e,t){let{sessionId:n,children:r}=t,i=p=>p===n||r.has(p),s=new Set,o=p=>{if(!i(p))throw new xe("SESSION_MISSING",`this host keeps session ${n} and its registered children, not ${p}`)},a=p=>e.call(I.stateGet,oe(n,p)),c=p=>{let l=a(p);return l===null||Yn(l)||p===n&&!s.has(p)&&u(l,p)?null:l},u=(p,l)=>An(p,e.call(I.chainRead,{name:"base.json",...oe(n,l)})!==null),g=(p,l)=>{e.call(I.statePut,{state:l,...oe(n,p)})},f=p=>({write(l,m){if(m==="state")return g(p,l);e.call(I.acknowledge,{pointer:l.checkpoint,side:t.side.snapshot(),...t.coverage(),state:l,...oe(n,p)})},complete(l){s.delete(p);let m=a(p);m!==null&&g(p,{...m,completed_at:t.now().toISOString(),ended:l})},release(){s.delete(p)}});return{expires:!1,create(p){if(!Dt.test(p.sid))throw new xe("SESSION_MISSING",`bad sid ${JSON.stringify(p.sid)}`);o(p.sid);let l=a(p.sid);if(l!==null&&(p.sid!==n||Yn(l)||s.has(p.sid)||!u(l,p.sid)))throw new xe("SESSION_LOCKED",`${p.sid} already exists \u2014 resume it`);let m=It(p);return g(p.sid,m),s.add(p.sid),Ve(m,f(p.sid))},resume(p){o(p);let l=c(p);if(l===null)throw new xe("SESSION_MISSING",`no session ${p}`);let m=Ot(l,t.now(),{expires:!1});return g(p,m),s.add(p),Ve(m,f(p))},peek:p=>i(p)?c(p):null,list(){let p=[n,...r.ids()].map(l=>({sid:l,state:c(l)}));return At(p.filter(l=>l.state!==null))},...Vt(t.chain,p=>(o(p),es(e.call(I.pointer,oe(n,p))))),appliedEvents:p=>t.sessionRecords(p).flatMap(l=>l.event_ids??[]),recordCount:(p,l)=>t.sessionRecords(p).filter(m=>m.seq<=l).length,isLive:p=>p===n||s.has(p),tidy:()=>{}}}function Yn(e){return typeof e?.completed_at=="string"}function es(e){let t=e;return typeof t=="object"&&t!==null&&Number.isInteger(t.seq)&&Number.isInteger(t.turn_id)&&typeof t.at=="string"&&typeof t.ts=="string"&&(t.full_seq===null||Number.isInteger(t.full_seq))?t:null}var Zn=500;function ts(e){let t=Buffer.alloc(e.length*4);return e.forEach((n,r)=>t.writeFloatLE(n,r*4)),t.toString("base64")}function ns(e){let t=Buffer.from(e,"base64"),n=new Float32Array(Math.floor(t.byteLength/4));for(let r=0;r<n.length;r++)n[r]=t.readFloatLE(r*4);return n}function Qn(e,t){let n=(c,u,g)=>`${c}
3
3
  ${u}
4
4
  ${g}`,r=new Map,i=new Set,s=new Map,o=!1,a=!1;return{prefetch(c,u,g){let f=`${c}
5
5
  ${u}`;if(!i.has(f)){i.add(f);try{let p=e.call(I.vectorsRead,{alias:c,purpose:u});for(let[l,m]of Object.entries(p.vectors)){let _=ns(m);_.length===g&&r.set(n(c,u,l),_)}}catch(p){if(o)return;o=!0,t(`the session could not read the vectors Lattice keeps, so it embeds what it needs (said once per session): ${Qe(p)}`)}}},read:(c,u,g)=>r.get(n(c,u,g))??null,write(c,u,g,f){r.set(n(c,u,g),f);let p=`${c}
@@ -7,6 +7,6 @@ ${u}
7
7
  ${f.length}`;s.has(p)||s.set(p,{alias:c,purpose:u,dims:f.length,vectors:new Map}),s.get(p).vectors.set(g,f)},writeBack(){if(s.size===0)return;let c=[...s.values()];s.clear();try{for(let{alias:u,purpose:g,dims:f,vectors:p}of c){let l=[...p];for(let m=0;m<l.length;m+=Zn){let _=Object.fromEntries(l.slice(m,m+Zn).map(([w,S])=>[w,ts(S)]));e.call(I.vectorsWrite,{alias:u,purpose:g,dims:f,vectors:_})}}}catch(u){if(a)return;a=!0,t(`Lattice did not keep this session's vectors, so a later session embeds them again (said once per session): ${Qe(u)}`)}}}}var we=e=>e.kind==="uc"?`uc:${e.id}`:e.kind;function Xn(e,t=()=>new Date){let n=new Map,r=new Map,i=(s,o)=>{for(let c of s){let u=n.get(we(c));u?u.count+=1:n.set(we(c),{grant:{owner_sid:e,pid:process.pid,ts:t().toISOString(),nonce:"memory",verb:o.verb??"session",hold:o.hold},count:1})}let a=!1;return{keys:s,assertHeld:()=>{},release:()=>{if(!a){a=!0;for(let c of[...s].reverse()){let u=n.get(we(c));u&&--u.count===0&&n.delete(we(c))}}},touch:()=>{}}};return{acquire:i,tryAcquire:i,holder:s=>n.get(we(s))?.grant??null,wait:async()=>"free",withKeySerialized:async(s,o)=>{let a=s.map(we).sort().join("|"),c=(r.get(a)??Promise.resolve()).then(o,o);return r.set(a,c.catch(()=>{})),c},releaseAll:()=>n.clear()}}function er(e=null,t=()=>{}){let n=e,r={proposals:structuredClone(n?.proposals??{}),signalLines:[...n?.signalLines??[]]},i=a=>r.proposals[a]??={proposal:null,review:null,verdicts:null},s={read:a=>structuredClone(r.proposals[a]?.proposal??null),write:(a,c)=>{i(a).proposal=structuredClone(c),t()},writeReview:(a,c)=>{i(a).review=structuredClone(c),t()},verdicts:a=>structuredClone(r.proposals[a]?.verdicts??{verdicts:{}}),saveVerdicts:(a,c)=>{i(a).verdicts=structuredClone(c),t()}},o={append:a=>{r.signalLines.push(JSON.stringify(a)),t()},snapshot:a=>{let c=[],u=0;for(let g of r.signalLines){let f=u+Buffer.byteLength(g)+1;if(a!==void 0&&f>a)break;c.push(JSON.parse(g)),u=f}return{signals:c,watermark:u}}};return{proposals:()=>s,signals:()=>o,snapshot:()=>structuredClone(r)}}function os(e,t){let n=[],r=null;do{let i=e.call(t,{after:r});n.push(...i.items),r=i.next}while(r!==null);return n}function rr(e,t){let n=e.call(I.scope,null),r=t.log??(()=>{}),i=new Set,s=Gn(e,n,r);s.readAhead(Object.values(s.baseIndex.heads).filter(d=>d!==null));let o=Qn(e,r),a=os(e,I.drafts).map(d=>({record:d.record,...d.attempt?{attempt:d.attempt}:{},envelope:d.envelope}));tr(t.sideDir,{recursive:!0});let c=nr(t.sideDir,"blobs"),u=e.call(I.pointer,null),g=u===null?e.call(I.sideGet,null):e.call(I.chainRead,{name:`side-${u.seq}.json`}),f=null,p=()=>{try{e.call(I.sideSave,{text:JSON.stringify(l.snapshot())})}catch(d){throw f=d,d}},l=er(g===null?null:JSON.parse(g),()=>p());t.publishSide?.(()=>{let d=f;if(f=null,d)throw d;p()});let m=null,_=d=>m.recordsSince(m.parse(n.baseHash)).filter(v=>v.sid===d),w=d=>{let{bytes:v}=e.call(I.getBlob,{fingerprint:d});return v===null?null:Buffer.from(v,"base64")},S=t.children??Ue(e),R=zn(e,{sessionId:t.sessionId,children:S,chain:Vn(e,t.sessionId,S),side:l,sessionRecords:_,coverage:()=>{let d=m.head(),v=d===null?null:m.resolveToken(d);return{eventSeq:t.lastEventSeq(),scope:v===null?{position:0,headHash:null}:{position:v.seq,headHash:v.hash}}},now:t.now??(()=>new Date)});return m=Hn({base:n.baseHash,index:d=>{if(d===n.baseHash)return structuredClone(s.baseIndex);if(d===null)return $e();let v=s.history.positionOf(d);if(v===null)throw new Error(`main holds no position ${d} up to the session's base`);return s.indexAt(v)},nodeBody:d=>s.nodeBody(d),prefetch:d=>s.prefetch(d),drafts:a,sink:d=>{let v=Pe(d.intent,{seq:d.record.seq,hash:d.hash,ts:d.record.ts}),k=e.call(I.appendDraft,{eventId:d.attemptId,record:d.record,envelope:v});return o.writeBack(),{record:k.record,hash:k.hash,replayed:k.replayed}},history:s.history,vectors:o,sides:{getBlob:w,putBlob:d=>{let v=Wt(d);if(t.knownBlobs?.includes(v)||i.has(v))return v;let{fingerprint:k}=e.call(I.putBlob,{bytes:d.toString("base64")});if(k!==v)throw new Error(`Lattice stored a blob under ${k}, not under its fingerprint ${v}`);return i.add(k),k},blobPath:d=>{let v=nr(c,d.replace(/[^A-Za-z0-9]/g,"_"));if(!rs(v)){let k=w(d);if(k===null)throw new Error(`Lattice holds no blob ${d}`);tr(c,{recursive:!0}),ss(v,k)}return v},logFile:()=>null,designFiles:()=>Jt(Jn(e)),parkedFacts:()=>{throw new Error("a session kept by Lattice parks no execution facts; execution sync is not part of a hosted session")},proposals:()=>l.proposals(),signals:()=>l.signals(),sessions:()=>R,locks:(d,v)=>Xn(d,v?.now)}}),m}var is=["override","agent"];function be(e){let{childSession:t,confirmUnreviewed:n,...r}=e;return async(i,s)=>{let o=s.onChildEvent?f=>s.onChildEvent({verb:"design",...f}):void 0,a=f=>{let p=On(f);p&&s.detail&&!s.detail.refused&&(s.detail.refused=p),o?.(f)},c=s.mode??"override";if(!is.includes(c))return a({type:"error",code:"MODE_USAGE",message:`error: a design child runs in override or agent mode, not '${c}'`,final:!0}),2;let u={...r,ask:async()=>[],out:()=>{},progress:()=>{},isTTY:!1,...o||s.detail?{emit:a}:{}};if(s.resume!==void 0)return it({resume:s.resume,mode:c},u);let g=t?.(i);return it({useCase:i,force:!0,mode:c,...s.because?{because:s.because}:{},...s.changeDelta!==void 0?{changeDelta:s.changeDelta}:{},...s.priorDesign!==void 0?{priorDesign:s.priorDesign}:{},...s.repinsKept?{repinsKept:!0}:{},...s.statement?{statement:s.statement}:{},...s.agentStatement?{agentStatement:s.agentStatement}:{},...n?{confirmUnreviewed:n}:{},...g?{sessionId:g.id,registerSession:f=>g.register(f)}:{}},u)}}function sr(e,t,n,r={}){return(i,s)=>ve({ucRef:i,verb:"evolve",force:!0,evolution:{...s.because?{because:s.because}:{},...s.changeDelta!==void 0?{changeDelta:s.changeDelta}:{},...s.priorDesign!==void 0?{priorDesign:s.priorDesign}:{},...r.changed?.(i)?{changed:!0}:{}},...s.statement?{statement:s.statement}:{},childSession:n(i),...r.quietEnding?{quietEnding:!0}:{},...r.onHeld?{onHeld:o=>r.onHeld(i,o)}:{}},e,t)}function z(e,t){let n=e.resolve(t);return(n?e.displayNameOf(n.tip):null)??t}var ae=(e,t)=>{let n=e.getNode(e.tipOf(t))?.content?.title;return typeof n=="string"&&n!==""?n:void 0};function as(e,t,n){return(r,i)=>{let s=t[r]??null,o=s!==null?Te(s):null,a=o&&s!==null?je(o.name,s,r):void 0,c=o&&s!==null?`${Qt([s])}${a?` --as ${Xe(a)}`:""}`:cs(e,r)?`kane-cli maintain reconcile --source-id ${Xe(r)}`:null,u=i!==void 0&&ds($(e),r,i);return!n||c===null?{cmd:c,remedy:T.reviewSource(c,r,u)}:{cmd:`${c} --mode agent`,remedy:T.reviewSourceAgent(u)}}}function ds(e,t,n){let r=e.heads.get(t);return typeof r!="string"||!e.extractedSourceCids.has(r)?!1:e.byLabel(Ae.GAP).some(({cid:i,content:s})=>{let o=s.basis;return s.kind==="reconcile_deferred"&&typeof s.uc=="string"&&e.tipOf(s.uc)===n&&o?.source_id===t&&o.to_cid===r&&!e.superseded.has(i)&&e.trust.get(i)!=="archived"})}function cs(e,t){let n=$(e),r=n.heads.get(t);if(typeof r!="string")return!1;let i=n.mediaOf(r);return i.format==="plugin"&&typeof i.plugin?.id=="string"&&typeof i.plugin.fetch?.ref=="string"}function ar(e,t){return{review:as(e,t.origins,t.agent),question(n,r,i,s){let o=$(e),a=ae(o,n.ucTip),c=a?`"${a}"`:n.display.toUpperCase(),u=r.total===1,g=Re(o,n.ucTip),f=g?`${c} changed after its ${u?"test was":"tests were"} designed`:`${c} hasn't changed since its tests were designed`,p=Le(o,n.ucTip),l=r.touched===0&&p.sources.length===0&&p.repinnable,m=g?u?{label:"update it",detail:r.touched>0?"its change touches its test":l?"its test isn't touched; saving marks it up to date":"its change doesn't touch its test"}:{label:"update them",detail:r.touched===r.total?`its change touches all ${r.total} of its tests`:r.touched===0?l?`none of its ${r.total} tests is touched; saving marks them up to date`:`its change touches none of its ${r.total} tests`:`only what its change touches: ${r.touched} of its ${r.total} tests`}:{label:"update them",detail:"only what your reason touches"},_=s?{label:"leave it out",detail:u?"its test stays out of date":"its tests stay out of date"}:{label:"stop here",detail:"nothing is started"};return{id:ye(n),header:"Update?",text:i?`${f}
8
8
  your reason: ${i}`:f,risk:"med",rationale:g?"updating designs its tests again: what its change touches is replaced, the rest stays as it is":"updating designs its tests again: only what your reason touches is replaced",options:[m,_],recommended_index:0,allow_free_text:!1}},answerWhy:n=>n==="proceed"?"update its tests":"leave it out"}}function dr(e,t,n,r,i){let s=$(e);if(Lt(s,t)!==null)return{refusal:T.ambiguousRef(t,r)};let o=Ye(s,t),a=at(s,o);if(!a.ok){let p=s.resolve(o);return p?s.nodeLabel.get(p.tip)===Ae.USECASE&&s.superseded.has(p.tip)?{refusal:{message:ne.removed(t,r).message}}:s.nodeLabel.get(p.tip)===Ae.USECASE&&s.trust.get(p.tip)==="archived"?{refusal:T.archived(ae(s,p.tip),z(s,o),r)}:{refusal:T.notInUseCase(t)}:{refusal:T.unknownRef(t,r)}}let c=z(s,a.target.ucTip),u=ae(s,a.target.ucTip);if(!ce(s,a.target.ucTip))return{refusal:T.noTests(u,c),noDesign:c};let g=lt(s,c,u,r);if(g)return{refusal:g};let f=Le(s,a.target.ucTip);return!n&&Nn(f)?{refusal:T.sourceChanged(u,c,ct(f.sources,i,a.target.ucTip)),sourceChanged:c}:!n&&!Re(s,a.target.ucTip)?{refusal:T.nothingChanged(u,c)}:null}function ls(e,t,n,r,i,s){let o=dr(e,t,n,r,i);if(o===null)return null;let a=o.refusal;return o.noDesign!==void 0?s({type:"evolve_skipped",use_case:o.noDesign,reason:"no-design",...a.next?{next:a.next}:{}}):o.sourceChanged!==void 0?s({type:"evolve_skipped",use_case:o.sourceChanged,reason:"source_changed",...a.remedy?{remedy:a.remedy}:{},...a.next?{next:a.next}:{}}):s({type:"error",...a.code?{code:a.code}:{},message:a.message,...a.next?{next:a.next}:{}}),2}function lt(e,t,n,r){let i=Tn(e,{useCase:t,resuming:!1});return i?.code==="UC_ARCHIVED"?T.archived(n,t,r):i?.code==="UC_UNREVIEWED"?T.unreviewed(n,t):null}async function cr(e){let{store:t,run:n}=e,r=ar(t,{origins:e.origins,agent:!0}),i=n.resume!==void 0,s=i&&n.kept!==void 0&&n.kept!=="unread"?n.kept:null,o=i?s?.request??(n.useCase?{ref:n.useCase,fromStale:!1}:{fromStale:!0}):{...n.ref!==void 0?{ref:n.ref}:{},fromStale:n.fromStale===!0,...n.because?{because:n.because}:{}};if(!i&&n.ref!==void 0){let C=ls(t,n.ref,n.because,e.projectName,r.review,e.emit);if(C!==null)return{code:C,unstarted:!0}}let a=i?pr(t,e.children,o,s):null,c=Bn(n.answer),u=a?{given:new Map([...a.keptGiven,...c.given]),...c.unreadable!==void 0?{unreadable:c.unreadable}:{}}:c;for(let C of a?.upToDate??[])e.emit({type:"evolve_skipped",use_case:C,reason:"up_to_date"});if(a?.nothingLeft)return{code:0,unstarted:!1};let g=!1,f=!1,p=()=>{f||(f=!0,e.logEvent({type:"evolve_answers",request:o,answers:[...u.given].flatMap(([C,h])=>typeof h=="string"?[{id:C,choice:h}]:[])}))},l=[],m=!1,_=C=>{l.includes(C)||l.push(C)},w=null,S=null,R=!1,d=C=>{if(C.type==="evolve_diff"&&R){R=!1;return}if(C.type==="evolve_diff"&&C.repinned&&(m=!0),!(w!==null&&(C.type==="session_paused"||C.type==="session_complete"))){if(w!==null){let h=Ee(C,{verb:"design",id:w});S!==null?S.push(h):e.emit(h);return}if(a){if(C.type==="evolve_skipped"&&C.reason==="declined"&&a.keptDeclines.has(`evolve:${String(C.use_case)}`)&&!c.given.has(`evolve:${String(C.use_case)}`)||C.type==="evolve_target"&&a.passedOver.has(`evolve:${String(C.use_case)}`))return;if(C.type==="evolve_paused"&&Array.isArray(C.pending_questions)){let h=C.pending_questions.map(E=>E.id),y=E=>`${me("design",e.sessionId,!0)} ${h.map(N=>`--answer ${N}=${E}`).join(" ")}`;e.emit({...C,next:[{cmd:y(1),why:"update its tests"},{cmd:y(2),why:"leave it out"}]});return}}if(C.type==="evolve_skipped"&&C.reason==="no-design"&&C.next===void 0){e.emit({...C,next:T.noTests(void 0,String(C.use_case)).next});return}e.emit(C)}},v=C=>[{cmd:`kane-cli maintain evolve ${C} --mode agent`,why:"update its tests later"}],k=(C,h,y,E,N={})=>e.emit({type:"child_end",child:"evolve",ok:E,use_case:C,dur_s:Math.max(1,Math.round((Date.now()-h)/1e3)),exit_code:y,...N}),x=(C,h,y,E,N,M)=>{let L=N===0&&(M||le(t,y,E)),q=N===3&&e.stopped();return k(C,h,N,L,{...L&&M?{outcome:"unchanged"}:{},...!L&&!q?{next:v(C)}:{}}),L&&!M&&(m=!0),!L&&!q&&_(C),N===3&&!q?1:N},P=async(C,h,y,E)=>{p(),g=!0;let N=Date.now(),M=!1;w=y,S=null,e.emit({type:"child_start",child:"evolve",subject:h,session_id:y});let L=1;try{L=await be(e.childRun)(C,{...E,mode:"override",resume:y,onChildEvent:q=>{q.type==="nothing_to_change"&&(M=!0),q.type!=="message_sent"&&E.onChildEvent?.(q)}})}catch(q){throw w=null,k(h,N,1,!1),q}return w=null,x(h,N,y,null,L,M)},K=async(C,h)=>{if(e.stopped())return 3;let y=$(t),E=z(y,C),N=lt(y,E,void 0,e.projectName);if(N)return e.emit({type:"evolve_skipped",use_case:E,reason:N.code==="UC_ARCHIVED"?"archived":"unreviewed",...N.next?{next:N.next}:{}}),R=!0,0;let M=a?.resumable.get(E);if(M!==void 0)return a.resumable.delete(E),P(C,E,M,h);let L=he(new Date),q=t.head(),ee=Date.now(),Se=!1,W=!1;w=L,S=[];let Q=(D,j,U={})=>k(E,ee,D,j,U),B=be({...e.childRun,childSession:()=>({id:L,register:D=>{p(),e.children.register(D,E),g=!0,W=!0,e.emit({type:"child_start",child:"evolve",subject:E,session_id:L});for(let j of S??[])e.emit(j);S=null}})}),V=1;try{V=await B(C,{...h,mode:"override",onChildEvent:D=>{D.type==="nothing_to_change"&&(Se=!0),D.type!=="message_sent"&&h.onChildEvent?.(D)}})}catch(D){if(w=null,S=null,D instanceof Ne&&D.code==="SESSION_CLASH"){let j=ge(D.extra?.heldBy);return e.emit({type:"evolve_skipped",use_case:E,reason:"held",...j?{held_by:{verb:j.verb,mine:j.mine}}:{},next:v(E)}),_(E),R=!0,0}throw W&&Q(1,!1),D}let A=S;if(w=null,S=null,!W){if(V===0)return V;e.emit({type:"child_start",child:"evolve",subject:E});for(let D of A??[])e.emit(D);return Q(V,!1,{next:v(E)}),_(E),V}return x(E,ee,L,q,V,Se)},F=await Fe(t,{...o.ref!==void 0?{ref:o.ref}:{},...o.because?{because:o.because}:{},mode:"override"},{io:{out:()=>{},err:(C,h)=>h?e.emit({type:"error",message:C.replace(/^error: /,""),code:h}):e.log(C),isTTY:!1,confirm:async()=>!1},asks:{blast:u},runDesign:K,onChild:()=>{},emit:d,by:{kind:"human",id:"owner"},words:r});if(g&&e.stopped()&&(F===0||F===3)){let C=me("design",e.sessionId,!0);return e.emit({type:"session_paused",sid:e.sessionId,mode:"agent",resume:C,expires_at:null,pending_questions:[],next:[{cmd:C,why:"goes on with the update where it stopped"}]}),{code:3,unstarted:!1}}return g&&e.logEvent({type:"evolve_not_updated",use_cases:l,still_stale:ur(t,e.children,new Set(u.given.keys()),l)}),o.ref===void 0&&l.length>0?{code:m?0:F===0?1:F,unstarted:!g&&!i,notUpdated:l}:{code:F,unstarted:!g&&!i}}function lr(e,t){let n=$(e),r=new Set,i=new Map;for(let s of t.ids()){let o;try{o=e.sessions().peek(s)?.use_case}catch{o=void 0}if(typeof o!="string"&&(o=e.recordsSince(null).find(u=>u.sid===s&&u.design_of)?.design_of?.uc_cid),typeof o!="string")continue;let a=z(n,o);le(e,s,null)?(r.add(a),i.delete(a)):r.has(a)||i.set(a,s)}return{done:r,resumable:i}}function ur(e,t,n,r){let i=$(e),{done:s}=lr(e,t);return dt(i).targets.filter(o=>ce(i,o.ucTip)&&!n.has(ye(o))).map(o=>z(i,o.ucTip)).filter(o=>!s.has(o)&&!r.includes(o))}function pr(e,t,n,r){let i=$(e),{done:s,resumable:o}=lr(e,t),a=m=>m.replace(/^evolve:/,""),c=new Set,u=new Set,g=!1,f=[];if(n.ref!==void 0){let m=at(i,Ye(i,n.ref));if(m.ok){let _=z(i,m.target.ucTip);s.has(_)?g=!0:!n.because&&!o.has(_)&&!Re(i,m.target.ucTip)?(f.push(_),g=!0):c.add(ye(m.target))}}else{for(let m of dt(i).targets)ce(i,m.ucTip)&&(s.has(z(i,m.ucTip))?u.add(ye(m)):c.add(ye(m)));for(let m of r?.answers??[])m.choice==="proceed"&&!c.has(m.id)&&!s.has(a(m.id))&&f.push(a(m.id))}let p=new Map([...(r?.answers??[]).filter(m=>c.has(m.id)).map(m=>[m.id,m.choice]),...[...u].map(m=>[m,"decline"])]),l=new Set([...p].filter(([,m])=>m==="decline").map(([m])=>m));return{done:s,resumable:o,keptGiven:p,keptDeclines:l,passedOver:u,asked:c,upToDate:f,nothingLeft:g}}async function fr(e){let{store:t,run:n}=e,r=ar(t,{origins:e.origins,agent:!1}),i=n.resume!==void 0,s=i&&n.kept!==void 0&&n.kept!=="unread"?n.kept:null,o=i?s?.request??(n.useCase?{ref:n.useCase,fromStale:!1}:{fromStale:!0}):{...n.ref!==void 0?{ref:n.ref}:{},fromStale:n.fromStale===!0,...n.because?{because:n.because}:{}};if(!i&&n.ref!==void 0){let d=dr(t,n.ref,n.because,e.projectName,r.review);if(d!==null)return await e.askMain({kind:"refused",message:d.refusal.message,...d.refusal.remedy?{next:d.refusal.remedy}:{}}),{code:2,unstarted:!0}}let a=i?pr(t,e.children,o,s):null,c={...o.ref!==void 0?{ref:o.ref}:{},...o.because?{because:o.because}:{},mode:"override"},u={out:()=>{},err:d=>e.log(d),isTTY:!1,confirm:async()=>!1},g={kind:"human",id:"owner"};if(a?.nothingLeft){let[d]=a.upToDate;if(d!==void 0){let v=$(t),k=v.resolve(d)?.tip,x=(k?ae(v,k):void 0)??d;await e.askMain({kind:"lines",lines:[{text:T.resumingOne(x,ir(t,a.resumable.get(d)),or)},T.upToDateNothing(x)],continues:!0})}return{code:0,unstarted:!1}}if(a&&[...a.asked].every(d=>a.keptGiven.has(d)))return await R(new Map(a.keptGiven));let f=[],p=null,l=[],m=await Fe(t,c,{io:u,asks:{blast:{given:new Map(a?.keptGiven??[])}},runDesign:async()=>{throw new Error("no update runs before its question is answered")},onChild:()=>{},emit:d=>{if(d.type==="evolve_paused"&&Array.isArray(d.pending_questions)&&(f=d.pending_questions),d.type==="evolve_batch"&&(p=Number(d.use_cases)),d.type==="evolve_skipped"&&d.reason==="source_changed"){let v=$(t),k=String(d.use_case),x=v.resolve(k)?.tip;l.push(...T.leftOutSourceChanged(x?ae(v,x):void 0,k,String(d.remedy??"")))}},by:g,words:r});if(m!==3||f.length===0)return m===0&&o.ref===void 0&&p===0&&await e.askMain(l.length>0?{kind:"lines",lines:l,stopped:!0}:{kind:"lines",lines:[{text:T.upToDate(e.projectName)}]}),{code:m===3?0:m,unstarted:!i};let _=new Map(a?.keptGiven??[]),w=[],S=f.filter(d=>{let v=$(t),k=z(v,d.id.replace(/^evolve:/,"")),x=v.resolve(k)?.tip,P=lt(v,k,void 0,e.projectName);return P?(P.code!=="UC_ARCHIVED"&&w.push(...T.cantUpdate((x?ae(v,x):void 0)??k,k)),_.set(d.id,"decline"),!1):!0});if(S.length===0&&!i)return await e.askMain({kind:"lines",lines:[...l,...l.length>0?[{text:""}]:[],{text:T.changedCount(f.length)},...w],stopped:!0}),{code:0,unstarted:!0};for(let[d,v]of S.entries()){let[k=v.text]=v.text.split(`
9
9
  `),x=d===0?[...i?[{text:T.moreAnswers(S.length)}]:[],...w]:[],P=await e.askMain({kind:"evolve-entry",head:k,...o.because?{reason:o.because}:{},options:v.options,...d===0&&o.ref===void 0&&!i?{batch:{useCases:f.length}}:{},...x.length>0?{before:x}:{},...d===0&&l.length>0?{lead:l}:{},last:d===S.length-1});if(!P.go&&P.code===130)return{code:130,unstarted:!0};_.set(v.id,P.go?"proceed":"decline")}return await R(_);async function R(d){if(!i&&![...d.values()].includes("proceed"))return{code:0,unstarted:!0};let{controller:v}=await e.mountChat(),k=!1,x=!1,P=!1,K=!1,F="",C=[],h=[],y=(A,D)=>{C.includes(A)||(C.push(A),h.push(D))},E=A=>{let D=$(t),j=D.resolve(A)?.tip??null,U=z(D,A);return{uc:U,title:(j?ae(D,j):void 0)??U,tip:j}},N=()=>{x||(x=!0,e.logEvent({type:"evolve_answers",request:o,answers:[...d].map(([A,D])=>({id:A,choice:D}))}))};if(a){let A=$(t),D=U=>{let te=A.resolve(U)?.tip;return(te?ae(A,te):void 0)??U},j=o.ref!==void 0?T.resumingOne(D(z(A,o.ref)),ir(t,a.resumable.get(z(A,o.ref))),or):T.resumingBatch(a.passedOver.size+[...d].filter(([U,te])=>te==="proceed"&&!a.passedOver.has(U)).length+a.upToDate.length,a.passedOver.size);v.ledger({kind:"lines",lines:[{text:j},...a.upToDate.map(U=>T.upToDateNow(D(U)))]})}let M={quietEnding:!0,changed:A=>{let{tip:D}=E(A);return D!==null&&Re($(t),D)},onHeld:(A,D)=>{let{uc:j,title:U}=E(A);K=!0,v.ledger({kind:"lines",lines:T.held(ge(D)?.mine===!0,U,j)}),y(j,U)}},L=sr(v,e.childRun,A=>(F=he(new Date),{id:F,register:D=>{N(),e.children.register(D,E(A).uc),k=!0}}),M),q=(A,D)=>(N(),k=!0,F=D,ve({ucRef:A,verb:"evolve",force:!0,resume:!0,childSession:{id:D,register:()=>{}},quietEnding:!0,evolution:{...M.changed(A)?{changed:!0}:{}}},v,e.childRun)),ee=A=>{let{tip:D}=E(A),j=D!==null?Le($(t),D).sources:[],{remedy:U}=ct(j,r.review,D??void 0);j.length>0&&U&&v.ledger({kind:"lines",lines:T.stillSourceChanged(U)})},Q=await Fe(t,c,{io:u,asks:{blast:{given:d}},runDesign:async(A,D)=>{if(e.stopped())return 3;let{uc:j,title:U}=E(A);K=!1;let te=a?.resumable.get(j);te!==void 0&&a.resumable.delete(j);let Ct=te!==void 0?null:t.head(),Ce=te!==void 0?await q(A,te):await L(A,D);return K?0:Ce===3&&e.stopped()?3:Ce===0&&le(t,F,Ct)?(P=!0,ee(A),0):Ce===0&&!t.recordsSince(Ct).some(Kr=>Kr.sid===F)?(D.onChildEvent?.({type:"nothing_to_change"}),ee(A),0):(v.ledger({kind:"lines",lines:T.later(j)}),y(j,U),Ce===3?1:Ce)},onChild:()=>{},emit:A=>{A.type==="evolve_diff"&&A.repinned&&(P=!0),e.logEvent(A)},by:g,words:r});if(e.stopped())return{code:3,unstarted:!k&&!i};let B=k?ur(t,e.children,new Set(d.keys()),C):[];k&&e.logEvent({type:"evolve_not_updated",use_cases:C,still_stale:B});let V=o.ref===void 0&&C.length>0;return(V||B.length>0)&&e.notUpdated(V?C:[],V?h:[],B.length),V?{code:P?0:Q===0?1:Q,unstarted:!k&&!i}:{code:Q,unstarted:!k&&!i}}}var or=4;function ir(e,t){return t===void 0?0:Mn(e.recordsSince(null).filter(n=>n.sid===t).map(n=>n.design_phase?.phase).filter(n=>typeof n=="string"))}function gr(e){return{verb:e.verb,mode:e.mode,contextRoot:null,env:Pt(),...e.run.resume!==void 0?{resumeSid:e.run.resume}:{},write:!0,longSession:!0,sessionId:e.supportId,remote:{sessionId:e.sessionId,projectId:e.projectId}}}function us(e,t=process.env){let n=e.TESTMUAI_BASIC_AUTH??t.TESTMUAI_BASIC_AUTH;if(n){let i=Buffer.from(n,"base64").toString("utf8"),s=i.indexOf(":");if(s>0)return{token:null,basic:{username:i.slice(0,s),accessKey:i.slice(s+1)}}}let r=e.TESTMUAI_API_KEY??t.TESTMUAI_API_KEY;return{token:r||null}}function ps(e,t=process.env){let n;return{controller:async()=>n??=us(e,t),lis:async()=>{throw new Error("a source plugin's connection carries the controller's credential only")}}}function mr(e,t={}){let n=ps(e);return r=>pn(r,{...t,credentials:n})}async function hr(e){let t=e.testing?.sourcePlugins;if(t){let n=await import(t.module),{registry:r,connections:i}=n.sourcePluginsFor(t.name,{auth:e.auth});nt(()=>r,i??mr(e.auth));return}nt(fn,mr(e.auth))}var X=(e,t,n)=>`${e} ${e===1?t:n}`,vr=e=>e.length<2?e.join(""):`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`,fs={"chat.added_use_cases":({minted:e,matched:t})=>e===0&&t>0?`${t===1?"1":`all ${t}`} matched existing \u2014 nothing new added`:`added ${X(e,"use-case","use-cases")} to this session`+(t>0?` \xB7 ${t} matched existing`:""),"chat.added_design":({acs:e,scenarios:t,tests:n,gaps:r,linked:i,update:s})=>{let o=[e?X(e,"acceptance criterion","acceptance criteria"):null,t?X(t,"scenario","scenarios"):null,n?X(n,"test","tests"):null,r?X(r,"open question","open questions"):null].filter(c=>c!==null),a=i?X(i,"scenario","scenarios"):null;return o.length?(s?`updated ${vr(o)} in this session`:`added ${vr(o)} to this session`)+(a?` \xB7 ${a} linked`:""):a?`linked ${a} to the acceptance criteria ${i===1?"it checks":"they check"}`:"updated this session's design"},"chat.proposal_refused":()=>"proposal failed validation \u2014 nothing added to this session","note.phase_unchanged":({update:e,kind:t,count:n})=>{if(!e||t===void 0||n===void 0)return"this phase matched what's already there \u2014 nothing new added";let[r,i]=t==="acs"?["acceptance criterion","acceptance criteria"]:t==="scenarios"?["scenario","scenarios"]:["test","tests"];return n===1?`its ${r} stays as it was`:`its ${n} ${i} stay as they were`},"chat.commit_failed":()=>"something couldn't be added to this session","chat.repair_sent":()=>"that couldn't be added to this session as it was \u2014 the agent is fixing it","chat.held_degraded":({held:e})=>`held ${X(e,"use-case","use-cases")} back \u2014 the duplicate check couldn't run fully, so nothing was added this turn; ${e===1?"it's":"they're"} kept with this session`,"chat.child_back":({drafts:e})=>`${e} added to this session`,"chat.refine_hint":({added:e,held:t})=>{let n=t===1?"the change":"the changes";return t===0?'chat to refine ("looks good" approves)':e===0?`chat to refine (${n} ${t===1?"is":"are"} kept with this session, not applied)`:`chat to refine ("looks good" approves new use-cases, not ${n})`},"chat.updates_held":({count:e})=>e===1?"held 1 change to an existing use-case \u2014 kept with this session, not applied":`held ${e} changes to existing use-cases \u2014 kept with this session, not applied`,"note.dedup_reduced":()=>"note: the duplicate check can't run fully, so from here on new use-cases are held back and this session will pause instead of finishing","note.chain_recovered":()=>"resuming from this session's last step","note.chain_truncated":({lost:e})=>e===1?"this session's last turn couldn't be read, so it resumes from before it":`this session's last ${e} turns couldn't be read, so it resumes from before them`,"chat.approved":({count:e})=>`approved ${X(e,"use-case","use-cases")}`,"chat.stales":()=>"","note.turns_unrecorded":()=>"note: this chat's messages can't be kept with the session \u2014 the agent has them now, but not after a resume","note.receipt_unbuilt":()=>"note: the change was added to this session, but the agent wasn't told, so it may not know about it","warning.variables_unwritten":()=>"warning: couldn't add the new variables to this folder; add them before running the tests","note.assumed_defaults":({count:e})=>`note: while you were away, ${e===1?"1 question was":`${e} questions were`} answered for you`,"note.checkpoint_not_saved":()=>"warning: couldn't keep this session's last step, so the session is pausing"},gs={"header.extract":({source:e,sources:t,index:n})=>n>1?{text:`extracting "${e}"`,tail:`source ${n} of ${t}`}:{text:`extracting "${e}"${t>1?` and ${t-1} more`:""}`,tail:`${X(t,"source","sources")} to read`},"header.resume_design":({use_case:e,done:t,phases:n})=>({text:`resuming "${e}"`,tail:`${t} of ${n} phases done`}),"header.design":({title:e,id:t,phases:n})=>({text:`designing tests for ${e!==null?`"${e}"`:Bt(t)}`,tail:`${X(n,"phase","phases")} to go`})},qe={...xt(_t,fs,gs),phaseNotesUnderAdded:!0};function yr(e,t){return t.size===0?e:{...e,sourceName:n=>t.get(n)}}function pt(e){return Ln({store:e.store,credentials:re,sessionId:e.sessionId,children:()=>e.children.ids(),childSession:t=>({id:Pn(new Date,t),register:n=>e.children.register(n)}),agent:e.agent.agent,...e.agent.auth?{auth:e.agent.auth}:{},...e.agent.preflightTurn?{preflightTurn:e.agent.preflightTurn}:{},...e.agent.probe?{probe:e.agent.probe}:{},...e.ask?{ask:e.ask}:{},...e.note?{note:e.note}:{},...e.narrate?{narrate:e.narrate}:{},...e.telemetry?{telemetry:e.telemetry,tracePath:Me}:{},matchUnreviewed:!0,by:e.by,emit:e.emit,changeSince:"cited"})}function wr(e,t,n){let r=new Map;for(let{key:i,card:s}of e)r.set(i,s.kind==="ADD"?`new-${t.indexOf(i)+1}`:Ie(n,s.ref));return r}function He(e,t){let n=r=>{let i=Number(/(\d+)$/.exec(r)?.[1]??Number.MAX_SAFE_INTEGER);return[r.startsWith("new-")?1:0,i]};return[...e].sort((r,i)=>{let[s,o]=n(t.get(r.key)??r.key),[a,c]=n(t.get(i.key)??i.key);return s-a||o-c})}function Ie(e,t){let n=e.resolve(t);return(n?e.displayNameOf(n.tip)??e.displayNameOf(n.cid)??t:t).toLowerCase()}function br(e,t,n){return e.map(({key:r,card:i,viewLines:s})=>{let o=t.get(r)??r,a=i.kind==="ADD"?null:n.resolve(i.ref),c=a?String(n.getNode(a.tip)?.content.title??i.title):i.title,u=i.kind==="MODIFY";return{key:o,kind:i.kind,...i.kind==="ADD"?{}:{use_case:o},title:c,change:i.why,...u?{diff:s.map(g=>({op:g.op,field:g.field,text:g.text})),tests:Oe(n,i.ref)}:{}}})}function Oe(e,t){return Be(e,t).filter(n=>e.nodeLabel.get(n)==="test").length}function kr(e,t,n,r=n){let i=$(t),s=i.heads.get(n),o=[];if(typeof s=="string"){if(ut?.head!==s){let a=null;try{a=Rn(t,i,s)}catch{a=null}ut={head:s,lines:a?.split(`
10
- `)??[]}}o=ut.lines}return e.map(a=>{let c={...a,card:{...a.card,...a.card.kind==="MODIFY"?{tests:Oe(i,a.card.ref)}:{},...a.card.diffSummary?{diffSummary:G.diffSummary(a.viewLines)}:{}}},u=Number(/L(\d+)/.exec(a.card.citeLines?.[0]??"")?.[1]);if(!Number.isInteger(u)||u<1||o.length===0)return c;let g=null;for(let f=Math.min(u,o.length)-1;f>=0&&g===null;f--)g=/^#+\s+(.+)$/.exec(o[f])?.[1]?.trim()??null;return{...c,card:{...c.card,provenance:`${gn(r)}, ${g??`line ${u}`}`}}})}var ut=null;function ft(e,t,n,r){let i=ce(e,n.key)!==null,s=r!==void 0?t.sessions().peek(r)?.force_scope:void 0;if(s!==void 0)return{verb:n.kind==="evolve"?"evolve":"design",replaces:s.filter(a=>e.nodeLabel.get(a)==="test").length,force:i};let o=Oe(e,n.key);return{...Rr(n.kind,o,i),replaces:o}}function Sr(e,t,n,r){let i={own:0,carried:0};for(let s of t)if(!n.has(s))try{let o=e.sessions().loadCheckpoint(s);i[o.base.verb==="design"?"carried":"own"]+=o.agent?.usage_total?.credits??0}catch(o){r(`resume: ${s}'s credits weren't counted: its checkpoint couldn't be read (${o instanceof Error?o.message:String(o)})`)}return i}function ms(e,t,n){try{return e.sessions().loadCheckpoint(t).agent?.usage_total?.credits??0}catch(r){return n?.(`resume: ${t}'s credits weren't counted: its checkpoint couldn't be read (${r instanceof Error?r.message:String(r)})`),0}}function Cr(e,t){let n=e.resumableChildren?.()[0];if(!n)return;let r=$(t),{verb:i,replaces:s}=ft(r,t,n.offer,n.child),o=r.resolve(n.offer.key),a=(o?r.getNode(r.tipOf(o.cid))?.content?.title:void 0)??n.offer.title;return{card:n.card,title:String(a),verb:i,replaces:s}}async function xr(e){let t=e.answer==="resume"?e.review.resumableChildren?.().find(d=>d.card===e.card):void 0,n=e.answer==="resume"?t:e.review.pendingOffers?.().find(d=>d.card===e.card);if(!n)return{code:2,verb:"design",tests:0,added:0};if(e.answer==="later")return e.review.offerAnswered?.(n.proposalId,e.card,"declined"),{code:0,verb:"design",tests:0,added:0};let r=$(e.store),{verb:i,force:s,replaces:o}=ft(r,e.store,n.offer,t?.child),a=i!=="evolve"?[]:t?hs(r,e.store.sessions().peek(t.child)?.force_scope??Be(r,n.offer.key),vs(e.store,t.child)):Be(r,n.offer.key),c=t?.child??he(new Date);t||e.review.offerAnswered?.(n.proposalId,e.card,"accepted",c);let u=st(e.parent.state.turns),g=n.offer.kind==="evolve"?Ie(r,n.offer.key):void 0,f=null,p=t?ms(e.store,t.child,e.log):0,l=e.parent.state.credits?.total,m=()=>{p>0&&e.parent.state.credits?.total===l&&e.parent.creditsCarriedIn?.(p)},_;try{_=await ve({ucRef:n.offer.key,force:s,verb:i,quietEnding:!0,...i==="evolve"&&o>0?{replaces:o}:{},...t?{resume:!0}:{},...!t&&i==="evolve"?{statement:_r(r,n.offer.key,o)}:{},childSession:{id:c,register:d=>e.children.register(d,g)},onEnded:d=>{e.review.offerEnded?.(n.proposalId,e.card,d)},onHeld:d=>{f=ge(d)}},e.parent,e.run)}catch(d){throw m(),d}if(_!==0&&m(),f!==null)return e.parent.ledger({kind:"lines",lines:G.childHeld(f.mine,g??Ie(r,n.offer.key))}),{code:_,verb:i,tests:0,added:0};let w=[...e.parent.state.ledger].reverse().find(d=>d.kind==="childClose"),S=_===0&&w?.kind==="childClose"?w.tests??0:0,R=w?.kind==="childClose"&&w.unfinished===!0;if(_===0&&!R){let d=e.designed.added+(i==="design"?S:0),v=i==="evolve"?G.againBack(ys($(e.store),a)):d>0?G.back(d):null;v!==null&&e.parent.ledger({kind:"lines",lines:[{text:v,dim:!0}]})}else if(!(_===3&&e.parent.state.status==="pausing")){let d=n.offer.kind==="evolve"?G.childFailedNext(Ie(r,n.offer.key),i).map(v=>({text:` ${v}`})):[{text:` ${G.childFailedNew}`,dim:!0}];e.parent.ledger({kind:"lines",lines:d})}return{code:_,verb:i,tests:S,added:st(e.parent.state.turns)-u}}function hs(e,t,n){let r=new Set(n.flatMap(o=>o.nodes.map(a=>a.cid))),i=n.flatMap(o=>o.supersessions.filter(a=>a.kind==="node").map(a=>a.old)),s=i.flatMap(o=>e.nodeLabel.get(o)==="scenario"?e.edgesInto(o).filter(a=>a.type==="automates").map(a=>a.src):[]);return[...new Set([...t,...i,...s])].filter(o=>!r.has(o))}function vs(e,t){try{let n=e.parse(e.sessions().loadCheckpoint(t).base.store_watermark);return e.recordsSince(n!==null&&e.resolveToken(n)!==null?n:null).filter(r=>r.sid===t)}catch{return[]}}function ys(e,t){let n={scenarios:0,tests:0},r=0,i=0,s=o=>String(e.getNode(o)?.content.title??"").trim().toLowerCase();for(let o of t){let a=e.nodeLabel.get(o);if(a!=="scenario"&&a!=="test")continue;if(!e.superseded.has(o)){a==="test"&&(i+=1);continue}let c=e.superseded.get(o);c&&s(c)===s(o)?a==="test"&&(r+=1):n[a==="test"?"tests":"scenarios"]+=1}return{replaced:n,updated:r,kept:i}}function _r(e,t,n){let r=e.resolve(t),i=r?e.displayNameOf(r.tip)??e.displayNameOf(r.cid)??t:t,s=r?String(e.getNode(r.tip)?.content?.title??i):i,o={id:i,title:s,replaces:n},a=o.replaces===1?"its test and the scenario it automates":`its ${o.replaces} tests and the scenarios they automate`;return[`[kane] ${o.id} "${o.title}" changed in this review: the person approved the change and chose to design its tests again.`,"Design them for its new version, phase by phase, each with finalize_design: acceptance criteria, scenarios, acceptance criteria + exercises, tests + gaps.",`Your phases replace ${a}, so don't edit those in a chat; acceptance criteria can still be edited in one.`].join(" ")}function Rr(e,t,n){return{verb:e==="evolve"&&t>0?"evolve":"design",force:n}}function Er(e,t){let n=null;for(let r of[...t.ids()].reverse()){let i;try{i=e.sessions().peek(r)?.reconcile?.proposal_id}catch(o){n??=o;continue}if(i===void 0)continue;let s=e.proposals().read(i);return s?s.use_cases.filter(o=>!o.matches_existing).map(o=>_n("ADD",o.temp_ref)):null}if(n!==null)throw n;return null}function gt(e){let t=$(e.store),{verb:n}=Rr(e.offer.kind,Oe(t,e.offer.key),ce(t,e.offer.key)!==null),r={kind:n,key:e.key,title:e.title};return n!=="evolve"?{offer:r}:{offer:r,run:async()=>{let i=e.review.pendingOffers?.().find(l=>l.card===e.card),s=he(new Date);i&&e.review.offerAnswered?.(i.proposalId,e.card,"accepted",s),e.emit({type:"child_start",child:"evolve",subject:e.key,session_id:s});let o=Date.now(),a=e.store.head(),c=be({...e.run,childSession:()=>({id:s,register:l=>e.children.register(l,e.key)})}),u=1,g=null,f,p={ok:!0};try{u=await c(e.offer.key,{yes:!0,mode:"override",agentStatement:_r(t,e.offer.key,Oe(t,e.offer.key)),onChildEvent:l=>{l.type==="error"&&f===void 0&&typeof l.message=="string"&&(f=l.message),l.type!=="message_sent"&&!Dr.has(l.type)&&e.emit(Ee(l,{verb:"design",id:s}))}})}catch(l){if(!(l instanceof Ne&&l.code==="SESSION_CLASH"))throw l;g=ge(l.extra?.heldBy),f=l.message,u=2}finally{let l=i!==void 0&&u===3&&e.stopped?.()===!0;i&&!l&&e.review.offerEnded?.(i.proposalId,e.card,"ran");let m=u===0&&le(e.store,s,a);e.emit({type:"child_end",child:"evolve",ok:m,dur_s:Math.max(1,Math.round((Date.now()-o)/1e3)),exit_code:u,...g!==null?{held_by:Zt(g)}:{},...!m&&!l?{next:[{cmd:`kane-cli maintain evolve ${e.key} --mode agent`,why:"update its tests later"}]}:{}}),p=m||l?{ok:!0}:{ok:!1,useCase:e.key,error:f?.replace(/^error: /,"")??(u===0?"it wrote no design with tests":`it ended with exit ${u}`)}}return p}}}var Dr=new Set(["session_paused","session_complete"]);async function Ir(e){for(let t of e.review.resumableChildren?.()??[]){let n=$(e.store),{verb:r}=ft(n,e.store,t.offer,t.child),i=Ie(n,t.offer.key);e.emit({type:"child_start",child:r,subject:i,session_id:t.child});let s=Date.now(),o=1;try{o=await be(e.run)(t.offer.key,{yes:!0,mode:"override",resume:t.child,onChildEvent:a=>{Dr.has(a.type)||e.emit(Ee(a,{verb:"design",id:t.child}))}})}finally{o===3&&e.stopped()||e.review.offerEnded?.(t.proposalId,t.card,"ran");let a=o===0&&le(e.store,t.child,null);e.emit({type:"child_end",child:r,ok:a,dur_s:Math.max(1,Math.round((Date.now()-s)/1e3)),exit_code:o,...!a&&!e.stopped()?{next:[r==="evolve"?{cmd:`kane-cli maintain evolve ${i} --mode agent`,why:"update its tests later"}:{cmd:`kane-cli design tests --use-case ${i} --mode agent`,why:"designs its tests again later"}]}:{}})}if(e.stopped())return!0}return!1}function Or(e,t){return[{cmd:`kane-cli context extract --resume ${e} --mode agent${t.map(n=>` --answer ${n}=approve`).join("")}`,why:"answer each change: approve, reject or defer"}]}var ws=["approve","reject","defer"];function mt(e){let t=e.filter(n=>/^q\d+=/i.test(n.trim()));return{questions:t,cards:e.filter(n=>!t.includes(n))}}function Ar(e,t){let n=i=>({kind:"refuse",code:"STRUCTURED_TARGET_UNKNOWN",error:i}),r=[];for(let i of e){let s=i.indexOf("="),o=(s>0?i.slice(0,s):i).trim().toLowerCase(),a=(s>0?i.slice(s+1):"").trim().toLowerCase();if(!t.includes(o))return n(`error: --answer ${o} names no card in this review; its cards are ${t.join(", ")}`);if(!ws.includes(a))return n(`error: --answer ${i.trim()} isn't a verdict; a card takes approve, reject or defer`);if(r.some(c=>c.key===o))return n(`error: --answer ${o} is given twice; answer each card once`);r.push({key:o,verdict:a})}return{kind:"apply",verdicts:r}}async function We(e){let t=0,n=new Map(e.items.map(r=>[e.keys.get(r.key)??r.key,r]));for(let{key:r,verdict:i}of e.verdicts){if(e.stopped?.())return{failedChildren:t};let s=n.get(r);if(!s)continue;let o;try{o=await e.review.applyVerdict(s.key,i)}catch(g){let f=g.code==="CONCURRENT_APPEND"?"CONCURRENT_APPEND":"CONNECTION_FAILED";e.emit({type:"card_refused",source:e.words.source,key:r,verdict:i,code:f,refusal:f==="CONCURRENT_APPEND"?G.refused(s.card,f,e.words).line:G.notLanded});continue}if(!o.ok){e.emit({type:"card_refused",source:e.words.source,key:r,verdict:i,code:o.code,refusal:G.refused(s.card,o.code,e.words).line});continue}let a=G.receipt(s.card,i),c=o.offer?e.onApproved?.(s,o.offer):void 0;e.emit({type:"card_verdict",source:e.words.source,key:r,verdict:i,line:a.line,...a.note?{note:a.note}:{},...c?.offer?{offer:c.offer}:{}});let u=await c?.run?.();u&&!u.ok&&(t++,e.emit({type:"error",code:"DESIGN_CHILD_FAILED",key:r,use_case:u.useCase,message:`the redesign of ${u.useCase} failed: ${u.error}`}))}return{failedChildren:t}}async function Pr(e){let t=s=>e.keys.get(s.key)??s.key,n=e.items.filter(s=>s.card.kind==="ARCHIVE"),{failedChildren:r}=await We({review:e.review,items:e.items,keys:e.keys,verdicts:e.items.map(s=>({key:t(s),verdict:s.card.kind==="ARCHIVE"?"defer":"approve"})),emit:e.emit,words:e.words,...e.onApproved?{onApproved:e.onApproved}:{},...e.stopped?{stopped:e.stopped}:{}});if(n.length>0&&e.emit({type:"reconcile_held",source_id:e.words.source,held:n.map(s=>({ref:t(s),why:s.card.why||s.card.title}))}),e.stopped?.())return{failed:r};let i=e.loadCards();if(i.length===0)return{failed:r};await We({review:e.review,items:i,keys:e.keys,verdicts:i.map(s=>({key:t(s),verdict:"defer"})),emit:e.emit,words:e.words});for(let s of i)e.emit({type:"error",code:"OVERRIDE_UNDECIDED",key:t(s),message:`the review couldn't decide card ${t(s)} (${s.card.title}) itself: it is left deferred, and the others went on`});return{failed:i.length+r}}function bs(e,t){let n=new Set;for(let r=t;r&&!n.has(r);r=e.superseded.get(r)){if(e.trust.get(r)==="archived")return!0;n.add(r)}return!1}function $r(e,t){let n=new Set(t),r=[...new Set(t.filter(s=>!bs(e,s)).map(s=>e.tipOf(s)))].filter(s=>n.has(s)&&e.hasNode(s));if(r.length===0)return null;let i=r.map(s=>{let o=e.getNode(s).content,a=e.displayNameOf(s);return{temp_ref:s,...a?{logical_id:a}:{},title:String(o.title??""),risk:String(o.risk??""),...typeof o.description=="string"?{description:o.description}:{}}});return{headline:qe.text("chat.added_use_cases",{minted:i.length,matched:0}),items:i}}var b=Ss;Rt(b.supportId);kn(b.traceVerb);var Z=ks,O=e=>Z.postMessage(e);Et(yr(qe,new Map((b.ingest??[]).flatMap(e=>e.remote?[[e.sourceId,hn({provider:e.remote.provider,display:e.remote.display,...e.remote.title!==void 0?{title:e.remote.title}:{}})]]:[]))),(e,t)=>O({type:"event",event:{type:"warning",message:e.replace(/^warning:\s*/,""),...t?{code:t}:{}}}),()=>b.supportId);var Cs=/^error: (agent failed|repair run failed|agent ended)/,jr=e=>b.run.resume===void 0?e:{...e,out:t=>en(t)?O({type:"log",line:t}):e.out(t)},pe=e=>O({type:"log",line:e});async function xs(){if(b.testing?.agent){let{standIn:t}=await import(b.testing.agent.module);return t(b.testing.agent.name)}let{runAgent:e}=await import("./bridge-T6QMYKED.js");return{agent:e}}function Mr(e){try{return structuredClone(e)}catch{return JSON.parse(JSON.stringify(e))}}function Lr(e){let t={};(e.state.pending?.questions??[]).forEach((i,s)=>t[s]=[...e.multiSelection(s)]);let n=new Set;for(let i of e.state.turns)for(let s of i.items??[])n.add(s.temp_ref);for(let i of e.state.activeTurn?.items??[])n.add(i.temp_ref);let r={};for(let i of n){let s=e.aliasOf(i);s!==void 0&&(r[i]=s)}return{multi:t,canIngest:!1,senderAlive:e.senderAlive(),aliases:r}}function _s(e,t){let{baseHash:n}=t.call(I.scope,null);return()=>e.recordsSince(e.parse(n)).flatMap(r=>r.nodes.filter(i=>i.label==="usecase").map(i=>i.cid))}function Rs(e,t){let n=_s(e,t);return{addedBefore:n,checkIn:()=>$r(se(e).graph(),n())}}async function bt(e,t){let{buildExtractChat:n}=await import("./extract-chat-M65NWGUK.js"),r=null,i=()=>{r&&O({type:"mirror",state:Mr(r.state),view:Lr(r)})},s=await n({site:se(e),store:e,credentials:re,agent:H.agent,auth:Y.auth,preflight:Y.preflightTurn,onRender:i,...Y.probe?{probe:Y.probe}:{},matchUnreviewed:!0,...t?{addedBefore:t.addedBefore,resumedCheckIn:t.checkIn}:{}});return r=s.controller,i(),Z.on("message",o=>{if(o.type!=="controller")return;if(o.member==="approveAdded"){Promise.resolve(s.controller.approveAdded()).then(c=>O({type:"approved",go:c}),()=>O({type:"approved",go:!1}));return}let a=s.controller[o.member];typeof a=="function"&&Promise.resolve(a.apply(s.controller,o.args)).catch(()=>{})}),s}async function Es(e,t,n,r,i){let s=await bt(t,i),o=i?e:{...e,sessionId:b.sessionId},a=i?[...i.addedBefore()]:null;return $n(o,{...jr(s.runDeps({isTTY:!0,onSummary:r,telemetry:de})),emit:n,note:pe,...a?{addedBefore:()=>a}:{}})}function Ge(e){return new Promise(t=>{let n=r=>{r.type==="preMountAnswer"&&(Z.off("message",n),t(r.answer))};Z.on("message",n),O({type:"preMount",question:e})})}async function Br(e,t,n){if(!e.useCase)return null;let r=e.useCase,[{designEntryGate:i},{designGate:s},{phaseLadderFor:o},{liveUseCase:a}]=await Promise.all([import("./trust-gate-AT2XBWN4.js"),import("./gate-WISOUTHQ.js"),import("./phase-seed-LCJ4WSYV.js"),import("./use-case-ref-NE4X4MZN.js")]),c=b.mode==="agent",u=se(t).graph(),g=async(R,d)=>{if(O({type:"unstarted"}),!c)return await Ge({kind:"refused",message:R.message,...R.next?{next:R.next.cmd?`${R.next.lead} ${R.next.cmd}`:R.next.lead}:{}}),2;let v=R.next?.cmd,k=v===void 0?void 0:d==="error"?[{cmd:v,why:R.next.why??R.next.lead}]:[{cmd:v,why:R.next.why??R.next.lead,title:"Redesign"},...R.more??[]];return n({type:d,...R.code?{code:R.code}:{},message:R.message,final:!0,...k?{next:k}:{}}),2},f=a(u,r);if(!f.ok){if(f.why==="unknown"){let R=[...u.names.keys()].filter(d=>d.startsWith("uc-")).sort().slice(0,6);return g(ne.unknown(r,b.projectName,R),"gate_refused")}return g(f.why==="removed"?ne.removed(r,b.projectName):ne.notUseCase(r,f.label),"gate_refused")}let p=u.getNode(f.cid)?.content?.title,l=typeof p=="string"&&p.trim()!==""?p:void 0,m;try{m=e.resume?t.sessions().peek(e.resume)?.use_case:void 0}catch{m=void 0}let _=i(u,{useCase:r,resuming:!!e.resume,sessionUseCase:m});if(_?.code==="UC_ARCHIVED")return g(ne.archived(l,r,b.projectName),"error");if(_?.code==="UC_UNREVIEWED"&&!e.allowUnreviewed)return g(ne.unapproved(l,r,c),"error");if(!c||e.resume)return null;let w=e.phase!==void 0&&o(t,u,r).length>0,S=s(u,r,!!e.force||w);return S.ok||!S.wall?null:g(ne.designed(l,r,S.wall.kind==="designed-stale"),"gate_refused")}async function Ds(e,t,n,r){let[{buildDesignChat:i},{runDesign:s,askedRedesign:o},{designGate:a},{captureForceScope:c}]=await Promise.all([import("./design-chat-F3OEZPNJ.js"),import("./run-PC5YO4AS.js"),import("./gate-WISOUTHQ.js"),import("./design-committer-TRYP3LOZ.js")]),u=se(t),g=await Br(e,t,n);if(g!==null)return g;let f=e;if(!e.resume&&e.useCase&&!e.phase){let w=u.graph(),S=a(w,e.useCase,!!e.force);if(!S.ok&&S.wall){let R=w.resolve(e.useCase)?.tip,d=R!==void 0?w.getNode(R)?.content?.title:void 0,v=await Ge({kind:"design-entry",wall:S.wall.kind,...typeof d=="string"&&d.trim()!==""?{title:d}:{},display:S.wall.display,testsReplaced:c(w,e.useCase).filter(k=>w.getNode(k)?.label==="test").length,sessionId:b.sessionId});if(!v.go)return v.code;f=v.because?o(f,v.because):{...f,...v.force?{force:!0}:{}}}}let p=await i({site:u,store:t,credentials:re,agent:H.agent,auth:Y.auth,preflight:Y.preflightTurn,...f.useCase?{useCase:f.useCase}:{},testFilesAt:"save"}),{controller:l}=p,m=()=>O({type:"mirror",state:Mr(l.state),view:Lr(l)});l.subscribe(m),m(),Z.on("message",w=>{if(w.type!=="controller")return;let S=l[w.member];typeof S=="function"&&Promise.resolve(S.apply(l,w.args)).catch(()=>{})});let _=async w=>(await Ge({kind:"retarget",message:Xt(w)})).go;return s({...jn(t,f),...b.fresh?{sessionId:b.sessionId}:{},confirmRetarget:_},{...jr(p.runDeps({isTTY:!0,onSummary:r,telemetry:de})),emit:n,note:pe})}function Is(e,t){try{let n=se(e).graph(),r=t.filter(s=>{let o=n.resolve(s);return o!==null&&n.getNode(o.tip)?.label==="test"}).length,i=Cn({graph:n,ids:t,cwd:b.projectDir});if(i.variables.length===0&&i.noStartPage.length===0)return;try{xn(i,b.projectDir)}catch(s){O({type:"log",line:`the variables the designed tests need couldn't be written to ${i.file}: ${ot(s)}`})}O({type:"needed",needed:i,tests:r})}catch(n){O({type:"log",line:`the designed tests' needs couldn't be read: ${ot(n)}`})}}var kt=Symbol("ready to write"),Fr=e=>new Proxy(e,{get:(t,n,r)=>n==="putBlob"?()=>{throw kt}:Reflect.get(t,n,r)});function Nr(e){let t=new Map;return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,i=>(t.has(n)||t.set(n,r(i)),t.get(n))]))}function Ur(e){let t=e instanceof Error?e.message:String(e),n=e?.code;return{code:typeof n=="string"?n:/^([A-Z][A-Z0-9_]+):\s*/.exec(t)?.[1]??/\s*\[([A-Z][A-Z0-9_]+)\]$/.exec(t)?.[1]??"INGEST_FAILED",message:t.replace(/^[A-Z][A-Z0-9_]+:\s*/,"").replace(/\s*\[[A-Z][A-Z0-9_]+\]$/,"")}}var qr=(b.ingest??[]).map(e=>e.fingerprint).filter(e=>typeof e=="string"&&e!=="");function Os(e){return new Promise(t=>{let n=r=>{r.type!=="ingestUploaded"||r.index!==e||(Z.off("message",n),r.ok&&r.fingerprint!==void 0&&qr.push(r.fingerprint),t(r.ok))};Z.on("message",n)})}function ht(e){return new Promise(t=>{let n=r=>{r.type!=="ingestGo"||r.index!==e||(Z.off("message",n),t(r.go))};Z.on("message",n)})}async function As(){if(b.testing?.remoteDeps){let e=await import(b.testing.remoteDeps.module);return{credentials:re,...e.remoteDepsFor(b.testing.remoteDeps.name)}}return{credentials:re}}async function Ps(e,t){let n=ln().byId(t.plugin.id);if(n===void 0)return{outcome:{outcome:"refused",code:"PLUGIN_MISSING",message:`${t.file} is read by plugin ${t.plugin.id}, which this build does not include`}};let r=un(),i={plugin:n,ref:t.plugin.ref,named:t.plugin.named,isFile:t.plugin.isFile,asId:t.sourceId},s=t.plugin.isFile?{bytes:t.bytes}:void 0,o=a=>tt({...i,store:a,supplied:s});try{return{outcome:{outcome:(await tt({...i,store:Fr(e),...s?{supplied:s}:{...r?{connect:r}:{},onFetched:c=>s=c}})).status==="unchanged"?"unchanged":"created"}}}catch(a){if(a instanceof cn){let{code:c,message:u,remedy:g}=a.refusal;return{outcome:{outcome:"refused",code:c,message:u,...g?{facts:{remedy:g}}:{}}}}return a!==kt?{outcome:{outcome:"refused",...Ur(a)}}:{outcome:{outcome:"created"},pluginWrite:o,...t.plugin.isFile?{}:{fetched:s.bytes}}}}async function $s(e,t,n){if(t.plugin)return Ps(e,t);let r=Buffer.from(t.bytes),i,s=t.file,o;if(t.remote){let a=dn(t.remote.provider),c=an(t.remote.mediaType);if(!a?.prepare||!c)return{outcome:{outcome:"refused",code:"UNSUPPORTED_MEDIA",message:`${t.file} can't be added`}};let u={provider:t.remote.provider,sourceId:t.sourceId,bytes:r,media:c,label:t.remote.label,display:t.remote.display,...t.remote.title!==void 0?{title:t.remote.title}:{},origin:t.remote.origin,identity:t.remote.identity,warnings:[],...t.remote.downloads?{downloads:t.remote.downloads}:{}},g=await a.prepare(u,e,await n());if(!g.ok){let{code:f,message:p,facts:l}=g.failure;return{outcome:{outcome:"refused",code:f,message:p,...l?{facts:l}:{}}}}({media:i,label:s}=g),o=Nr(g.converters)}else{let a=on(t.file);if(!a.ok)return{outcome:{outcome:"refused",code:a.code,message:`${t.file} is a file type kane can't ingest`}};i=a.media,o=Nr({pdf:rn,docx:sn})}try{return{outcome:{outcome:(await et({store:Fr(e),bytes:r,media:i,sourceId:t.sourceId,label:s,converters:o})).status==="unchanged"?"unchanged":"created"},write:{bytes:r,media:i,label:s,converters:o}}}catch(a){return a===kt?{outcome:{outcome:"created"},write:{bytes:r,media:i,label:s,converters:o}}:{outcome:{outcome:"refused",...Ur(a)}}}}async function Ns(e,t,n){let r=null,i=()=>r??=As(),s=[];for(let c of t)s.push(await $s(e,c,i));let o=s.findIndex(c=>c.outcome.outcome==="refused");if(o>=0)return O({type:"ingestOutcome",index:o,...s[o].outcome}),await ht(o),2;if(t.length>1){let c=$(e),u=s.flatMap((g,f)=>g.outcome.outcome==="created"&&c.heads.get(t[f].sourceId)!=null?[f]:[]);if(u.length>0)return O({type:"ingestOutcome",index:u[0],outcome:"refused",code:"NEW_VERSION_ALONE",message:"a new version is reviewed on its own",facts:{newVersions:u.join(",")}}),await ht(u[0]),2}for(let[c,u]of s.entries())if(u.fetched!==void 0&&(O({type:"ingestFetched",index:c,bytes:u.fetched}),!await Os(c)))return 2;for(let[c,u]of s.entries())if(O({type:"ingestOutcome",index:c,...u.outcome}),!await ht(c))return 2;let a=null;for(let[c,u]of t.entries()){let g=s[c],f=u.plugin!==void 0&&!u.plugin.isFile,p=f?Tr(e,u.sourceId):null,l=g.outcome.outcome==="refused"?"unchanged":g.outcome.outcome,m=[],_=null,w,S=null;if(g.outcome.outcome==="created"&&(g.write||g.pluginWrite))try{let k=g.pluginWrite?await g.pluginWrite(e):await et({store:e,sourceId:u.sourceId,...g.write});if(l=k.status,m=k.warnings??[],k.status==="created"&&(w=Ts(e,u.sourceId,k.blob)),k.composite){let{kind:x,pages:P,delivered:K,omitted:F}=k.composite;_={kind:x,...P!==void 0?{pages:P}:{},delivered:K,omitted:F},u.remote&&K+F>0&&(S={delivered:K,omitted:F})}}catch(k){return O({type:"log",line:`the source wasn't written after its result was taken: ${k instanceof Error&&k.stack?k.stack:String(k)}`}),O({type:"ingestUnwritten",index:c}),2}let R=b.verb==="reconcile"&&l==="unchanged"?En(e,u.sourceId):null,d=R?.behind.length??0,v=R?.unread===!0;u.then==="review"&&(a={status:l,behind:d,unread:v}),n({type:"ingested",source_id:u.sourceId,status:l,...d>0?{behind:d}:{},...v?{unread:!0}:{},...f?{cursor:{from:p,to:Tr(e,u.sourceId)}}:{},...m.length>0?{warnings:m}:{},..._?{media:_}:{},...w?{duplicate_of:w}:{},...u.remote?{origin:u.remote.origin}:{}}),O({type:"ingested",index:c,status:l,...d>0?{behind:d}:{},...v?{unread:!0}:{},...w?{duplicateOf:w}:{},...S?{attachments:S}:{}})}return t[0]?.then==="review"&&a!==null&&a.status==="unchanged"&&a.behind===0&&!a.unread||t[0]?.then==="pause"?0:null}function Tr(e,t){let n=$(e),r=n.heads.get(t);return typeof r=="string"?n.mediaOf(r).plugin?.fetch?.cursor??null:null}function Ts(e,t,n){let r=$(e);for(let[i,s]of r.heads.entries())if(i!==t&&s!=null&&r.getNode(s)?.content.blob===n)return i}var St=()=>b.ingest?.[0]?.sourceId??b.review.sourceId,js=()=>b.ingest?.[0]?.file??b.review?.file??"<file>",yt=e=>{let t=St(),n=b.ingest?.[0]?.remote,r=b.review?.page,i;if(n)i=vn({...n,address:n.origin.url},je(n.provider,n.origin.url,t));else if(r){let s=Te(r.address)?.name??"web";i=wn(s,r.address,yn(e,t),r.as)}return{source:t,file:js(),...i?{page:i}:{}}},Hr=e=>e.pending()===null&&(e.givenVerdicts?.().length??0)>0,wt=e=>b.run.resume!==void 0&&(e.pending()?.kind==="cards"||Hr(e));function ke(e,t){return{store:e,projectDir:null,agent:t.agent,credentials:re,...t.auth?{auth:t.auth}:{},...t.preflightTurn?{preflightTurn:t.preflightTurn}:{},testFilesAt:"save",note:pe,telemetry:de,tracePath:Me}}var Ms=new Set(["reasoning_delta","reasoning_done","tool_activity","decision_activity","usage","text_delta","progress"]);async function Ls(e,t,n,r){let i=St(),s=yt(e),o=mn(s);O({type:"reviewMirror",review:{pending:null,cards:[],lastReadError:null,given:[],named:s}});let c=(await bt(e)).controller,u=null,g=pt({store:e,note:d=>O({type:"log",line:`review: ${d}`}),children:t,sessionId:b.sessionId,by:{kind:"human",id:"owner"},agent:n,telemetry:de,ask:d=>c.ask(d),narrate:d=>{d.type==="proposal"?u=d.narrative??null:Ms.has(d.type)&&c.onAgentEvent(d)},emit:r});if(b.run.resume!==void 0){let d=Sr(e,t.ids(),new Set((g.resumableChildren?.()??[]).map(v=>v.child)),v=>O({type:"log",line:v}));d.own+d.carried>0&&c.creditsSoFar?.(d.own+d.carried,d.carried)}let f={again:0,added:0},p=async(d,v)=>{let k=await xr({review:g,store:e,children:t,parent:c,run:ke(e,n),card:d,answer:v,designed:f,log:x=>O({type:"log",line:x})});return k.code===0&&(f[k.verb==="evolve"?"again":"added"]+=k.tests),k.code===3&&c.state.status==="pausing"&&(m.push({type:"pause"}),_?.()),k},l,m=[],_=null,w=c.attachSender(d=>{m.push(d),_?.()}),S=async()=>{for(;m.length===0;)await new Promise(d=>_=d);return m.shift()},R=async d=>{c.setWorking?.(`Reading ${s.page?.reading??i}\u2026`);let v=await d(),k=g.loadCards();return l.mirror(),c.setWorking?.(null),c.narrated?.(u,k.length>0?{kind:"commit",ok:!0,held:!0,line:G.held(o,k.map(x=>x.card.kind))}:void 0),u=null,v};l=bn({...g,loadCards:()=>kr(g.loadCards(),e,i,o),offer:p,...g.steer?{steer:d=>R(()=>g.steer(d))}:{}},O,d=>O({type:"log",line:d}),s,b.run.resume!==void 0?()=>Cr(g,e):void 0),c.ledger({kind:"header",text:G.header(o),tail:""}),Z.on("message",d=>{d.type==="review"&&l.serve(d)});try{if(!wt(g)){let d=await R(()=>g.startReview(i));if(d!==3)return d!==0&&H.interrupted()?3:d}for(;;){let d=await S();if(d.type==="session_complete")return 0;if(d.type==="pause")return 3;d.type==="user_message"&&d.text&&g.steer&&await R(()=>g.steer(d.text))}}finally{w()}}async function Bs(e,t,n,r){let i=St(),s=b.run.override===!0?Dn(e):new Set,o=[],a=null,c=pt({store:e,note:w=>O({type:"log",line:`review: ${w}`}),children:t,sessionId:b.sessionId,by:{kind:"human",id:"owner"},agent:r,telemetry:de,emit:w=>{if(w.type==="review_cards")return void(o=w.dropped);if(!(w.type==="card_verdict"||w.type==="card_refused")){if(w.type==="review_resolved")return void(a=w);w.child_id!==void 0&&(w.type==="session_paused"||w.type==="session_complete")||n(w)}}});n({type:"run_start"});let u=me("extract",b.sessionId,!0),g=w=>n({type:"session_paused",sid:b.sessionId,source_id:i,mode:"agent",resume:u,expires_at:null,pending_questions:[],next:[{cmd:u,why:"resume"}],...w});if(b.run.resume!==void 0&&await Ir({review:c,store:e,run:ke(e,r),emit:n,stopped:H.interrupted}))return g({}),3;if(wt(c)&&Hr(c))return 0;if(!wt(c)){let w=await c.startReview(i);if(w!==3)return w!==0&&H.interrupted()?(g({}),3):w}let f=c.loadCards(),p=$(e),l=wr(f,Er(e,t)??f.filter(w=>w.card.kind==="ADD").map(w=>w.key),p);if(f=He(f,l),b.run.override===!0){let w=ke(e,r),S=b.testing?.refuseCard,R=S?Object.assign(Object.create(c),{applyVerdict:async(v,k,x)=>v===S||l.get(v)===S?{ok:!1,code:"CONCURRENT_APPEND",refusal:"the store moved under the review (test)"}:c.applyVerdict(v,k,x)}):c,d=await Pr({review:R,items:f,keys:l,emit:n,words:yt(e),loadCards:()=>He(c.loadCards(),l),onApproved:(v,k)=>gt({review:c,store:e,children:t,run:w,emit:n,card:v.key,key:l.get(v.key)??v.key,offer:k,title:rt(v.card),stopped:H.interrupted}),stopped:H.interrupted});return a&&n(a),n({type:"reconcile_use_cases",source_id:i,use_cases:In(e,i,s)}),d.failed>0&&O({type:"itemsFailed",count:d.failed}),H.interrupted()?(g({}),3):0}let m=mt(b.run.answer??[]).cards;if(m.length>0){let w=Ar(m,f.map(d=>l.get(d.key)??d.key));if(w.kind==="refuse")return n({type:"error",message:w.error,code:w.code}),2;let S=ke(e,r),R=await We({review:c,items:f,keys:l,verdicts:w.verdicts,emit:n,words:yt(e),onApproved:(d,v)=>gt({review:c,store:e,children:t,run:S,emit:n,card:d.key,key:l.get(d.key)??d.key,offer:v,title:rt(d.card),stopped:H.interrupted}),stopped:H.interrupted});if(a&&n(a),R.failedChildren>0&&O({type:"itemsFailed",count:R.failedChildren}),f=He(c.loadCards(),l),f.length===0&&H.interrupted())return(c.resumableChildren?.()??[]).length>0?(g({}),3):(g({reason:"review_decided",pending_cards:[],next:[{cmd:me("extract",b.sessionId,!0),why:"finish the review"}]}),3);if(f.length===0)return 0}n({type:"review_cards",source:i,cards:br(f,l,p),dropped:o});let _=f.map(w=>l.get(w.key)??w.key);return g({reason:"review_pending",pending_cards:_,next:Or(b.sessionId,_)}),3}var Ke,vt=new Set,Wr=await xs(),de=$t(gr(b)),H=Fn(Wr.agent,()=>{},null),Y={auth:{...b.auth,...de.spawnEnv()},...Wr,preflightTurn:async()=>b.preflight,telemetry:de,agent:H.agent},Gr=!1,Fs=()=>H.interrupted()||Gr;Z.on("message",e=>{e.type==="stop"&&H.interrupt(),e.type==="kill"&&H.kill(),e.type==="controller"&&e.member==="requestPause"&&(Gr=!0)});try{await hr(b);let e=new zt(b.bridge,45e4),t=b.lastEventSeq,n=Ue(e),r=rr(e,{sessionId:b.sessionId,sideDir:b.sideDir,children:n,lastEventSeq:()=>t,log:x=>O({type:"log",line:x}),knownBlobs:qr}),i=x=>{t+=1,O({type:"sessionEvent",seq:t,kind:x.type,payload:x})},s=x=>{if(!(H.interrupted()&&x.type==="error"&&Cs.test(String(x.message??"")))){if(x.type==="commit")for(let P of x.minted??[])typeof P.logical_id=="string"&&vt.add(P.logical_id);t+=1,O({type:"sessionEvent",seq:t,kind:x.type,payload:x}),O({type:"event",event:x})}},{run:o}=b,a=b.landed??[],c=b.verb==="extract"&&o.resume!==void 0&&a.length>0&&e.call(I.stateGet,{})===null,u=b.fresh||c,g=[...new Set((b.ingest??[]).map(x=>x.sourceId))],f=g.length>1?g:c?a:[],p=b.verb==="reconcile"?mt(o.answer??[]).questions:b.verb==="evolve"?[]:o.answer??[],l=p.length?nn({opts:{resume:o.resume,answer:p},reader:r.sessions(),verb:b.verb==="design"?"design":"extract"}):{kind:"none"};if(l.kind==="apply"){let x=P=>b.verb==="design"?s({type:"note",text:P}):pe(P);for(let P of l.notes)x(P);l.matchedQids.length>0&&x(`applying ${l.matchedQids.length} structured answer(s) from --answer to the paused session's pending questions`);for(let P of l.matchedQids)s({type:"panel_resolved",id:P,by:"user",via:"flag"})}let m=l.kind==="apply"&&l.statement?[o.message,l.statement].filter(Boolean).join(`
10
+ `)??[]}}o=ut.lines}return e.map(a=>{let c={...a,card:{...a.card,...a.card.kind==="MODIFY"?{tests:Oe(i,a.card.ref)}:{},...a.card.diffSummary?{diffSummary:G.diffSummary(a.viewLines)}:{}}},u=Number(/L(\d+)/.exec(a.card.citeLines?.[0]??"")?.[1]);if(!Number.isInteger(u)||u<1||o.length===0)return c;let g=null;for(let f=Math.min(u,o.length)-1;f>=0&&g===null;f--)g=/^#+\s+(.+)$/.exec(o[f])?.[1]?.trim()??null;return{...c,card:{...c.card,provenance:`${gn(r)}, ${g??`line ${u}`}`}}})}var ut=null;function ft(e,t,n,r){let i=ce(e,n.key)!==null,s=r!==void 0?t.sessions().peek(r)?.force_scope:void 0;if(s!==void 0)return{verb:n.kind==="evolve"?"evolve":"design",replaces:s.filter(a=>e.nodeLabel.get(a)==="test").length,force:i};let o=Oe(e,n.key);return{...Rr(n.kind,o,i),replaces:o}}function Sr(e,t,n,r){let i={own:0,carried:0};for(let s of t)if(!n.has(s))try{let o=e.sessions().loadCheckpoint(s);i[o.base.verb==="design"?"carried":"own"]+=o.agent?.usage_total?.credits??0}catch(o){r(`resume: ${s}'s credits weren't counted: its checkpoint couldn't be read (${o instanceof Error?o.message:String(o)})`)}return i}function ms(e,t,n){try{return e.sessions().loadCheckpoint(t).agent?.usage_total?.credits??0}catch(r){return n?.(`resume: ${t}'s credits weren't counted: its checkpoint couldn't be read (${r instanceof Error?r.message:String(r)})`),0}}function Cr(e,t){let n=e.resumableChildren?.()[0];if(!n)return;let r=$(t),{verb:i,replaces:s}=ft(r,t,n.offer,n.child),o=r.resolve(n.offer.key),a=(o?r.getNode(r.tipOf(o.cid))?.content?.title:void 0)??n.offer.title;return{card:n.card,title:String(a),verb:i,replaces:s}}async function xr(e){let t=e.answer==="resume"?e.review.resumableChildren?.().find(d=>d.card===e.card):void 0,n=e.answer==="resume"?t:e.review.pendingOffers?.().find(d=>d.card===e.card);if(!n)return{code:2,verb:"design",tests:0,added:0};if(e.answer==="later")return e.review.offerAnswered?.(n.proposalId,e.card,"declined"),{code:0,verb:"design",tests:0,added:0};let r=$(e.store),{verb:i,force:s,replaces:o}=ft(r,e.store,n.offer,t?.child),a=i!=="evolve"?[]:t?hs(r,e.store.sessions().peek(t.child)?.force_scope??Be(r,n.offer.key),vs(e.store,t.child)):Be(r,n.offer.key),c=t?.child??he(new Date);t||e.review.offerAnswered?.(n.proposalId,e.card,"accepted",c);let u=st(e.parent.state.turns),g=n.offer.kind==="evolve"?Ie(r,n.offer.key):void 0,f=null,p=t?ms(e.store,t.child,e.log):0,l=e.parent.state.credits?.total,m=()=>{p>0&&e.parent.state.credits?.total===l&&e.parent.creditsCarriedIn?.(p)},_;try{_=await ve({ucRef:n.offer.key,force:s,verb:i,quietEnding:!0,...i==="evolve"&&o>0?{replaces:o}:{},...t?{resume:!0}:{},...!t&&i==="evolve"?{statement:_r(r,n.offer.key,o)}:{},childSession:{id:c,register:d=>e.children.register(d,g)},onEnded:d=>{e.review.offerEnded?.(n.proposalId,e.card,d)},onHeld:d=>{f=ge(d)}},e.parent,e.run)}catch(d){throw m(),d}if(_!==0&&m(),f!==null)return e.parent.ledger({kind:"lines",lines:G.childHeld(f.mine,g??Ie(r,n.offer.key))}),{code:_,verb:i,tests:0,added:0};let w=[...e.parent.state.ledger].reverse().find(d=>d.kind==="childClose"),S=_===0&&w?.kind==="childClose"?w.tests??0:0,R=w?.kind==="childClose"&&w.unfinished===!0;if(_===0&&!R){let d=e.designed.added+(i==="design"?S:0),v=i==="evolve"?G.againBack(ys($(e.store),a)):d>0?G.back(d):null;v!==null&&e.parent.ledger({kind:"lines",lines:[{text:v,dim:!0}]})}else if(!(_===3&&e.parent.state.status==="pausing")){let d=n.offer.kind==="evolve"?G.childFailedNext(Ie(r,n.offer.key),i).map(v=>({text:` ${v}`})):[{text:` ${G.childFailedNew}`,dim:!0}];e.parent.ledger({kind:"lines",lines:d})}return{code:_,verb:i,tests:S,added:st(e.parent.state.turns)-u}}function hs(e,t,n){let r=new Set(n.flatMap(o=>o.nodes.map(a=>a.cid))),i=n.flatMap(o=>o.supersessions.filter(a=>a.kind==="node").map(a=>a.old)),s=i.flatMap(o=>e.nodeLabel.get(o)==="scenario"?e.edgesInto(o).filter(a=>a.type==="automates").map(a=>a.src):[]);return[...new Set([...t,...i,...s])].filter(o=>!r.has(o))}function vs(e,t){try{let n=e.parse(e.sessions().loadCheckpoint(t).base.store_watermark);return e.recordsSince(n!==null&&e.resolveToken(n)!==null?n:null).filter(r=>r.sid===t)}catch{return[]}}function ys(e,t){let n={scenarios:0,tests:0},r=0,i=0,s=o=>String(e.getNode(o)?.content.title??"").trim().toLowerCase();for(let o of t){let a=e.nodeLabel.get(o);if(a!=="scenario"&&a!=="test")continue;if(!e.superseded.has(o)){a==="test"&&(i+=1);continue}let c=e.superseded.get(o);c&&s(c)===s(o)?a==="test"&&(r+=1):n[a==="test"?"tests":"scenarios"]+=1}return{replaced:n,updated:r,kept:i}}function _r(e,t,n){let r=e.resolve(t),i=r?e.displayNameOf(r.tip)??e.displayNameOf(r.cid)??t:t,s=r?String(e.getNode(r.tip)?.content?.title??i):i,o={id:i,title:s,replaces:n},a=o.replaces===1?"its test and the scenario it automates":`its ${o.replaces} tests and the scenarios they automate`;return[`[kane] ${o.id} "${o.title}" changed in this review: the person approved the change and chose to design its tests again.`,"Design them for its new version, phase by phase, each with finalize_design: acceptance criteria, scenarios, acceptance criteria + exercises, tests + gaps.",`Your phases replace ${a}, so don't edit those in a chat; acceptance criteria can still be edited in one.`].join(" ")}function Rr(e,t,n){return{verb:e==="evolve"&&t>0?"evolve":"design",force:n}}function Er(e,t){let n=null;for(let r of[...t.ids()].reverse()){let i;try{i=e.sessions().peek(r)?.reconcile?.proposal_id}catch(o){n??=o;continue}if(i===void 0)continue;let s=e.proposals().read(i);return s?s.use_cases.filter(o=>!o.matches_existing).map(o=>_n("ADD",o.temp_ref)):null}if(n!==null)throw n;return null}function gt(e){let t=$(e.store),{verb:n}=Rr(e.offer.kind,Oe(t,e.offer.key),ce(t,e.offer.key)!==null),r={kind:n,key:e.key,title:e.title};return n!=="evolve"?{offer:r}:{offer:r,run:async()=>{let i=e.review.pendingOffers?.().find(l=>l.card===e.card),s=he(new Date);i&&e.review.offerAnswered?.(i.proposalId,e.card,"accepted",s),e.emit({type:"child_start",child:"evolve",subject:e.key,session_id:s});let o=Date.now(),a=e.store.head(),c=be({...e.run,childSession:()=>({id:s,register:l=>e.children.register(l,e.key)})}),u=1,g=null,f,p={ok:!0};try{u=await c(e.offer.key,{yes:!0,mode:"override",agentStatement:_r(t,e.offer.key,Oe(t,e.offer.key)),onChildEvent:l=>{l.type==="error"&&f===void 0&&typeof l.message=="string"&&(f=l.message),l.type!=="message_sent"&&!Dr.has(l.type)&&e.emit(Ee(l,{verb:"design",id:s}))}})}catch(l){if(!(l instanceof Ne&&l.code==="SESSION_CLASH"))throw l;g=ge(l.extra?.heldBy),f=l.message,u=2}finally{let l=i!==void 0&&u===3&&e.stopped?.()===!0;i&&!l&&e.review.offerEnded?.(i.proposalId,e.card,"ran");let m=u===0&&le(e.store,s,a);e.emit({type:"child_end",child:"evolve",ok:m,dur_s:Math.max(1,Math.round((Date.now()-o)/1e3)),exit_code:u,...g!==null?{held_by:Zt(g)}:{},...!m&&!l?{next:[{cmd:`kane-cli maintain evolve ${e.key} --mode agent`,why:"update its tests later"}]}:{}}),p=m||l?{ok:!0}:{ok:!1,useCase:e.key,error:f?.replace(/^error: /,"")??(u===0?"it wrote no design with tests":`it ended with exit ${u}`)}}return p}}}var Dr=new Set(["session_paused","session_complete"]);async function Ir(e){for(let t of e.review.resumableChildren?.()??[]){let n=$(e.store),{verb:r}=ft(n,e.store,t.offer,t.child),i=Ie(n,t.offer.key);e.emit({type:"child_start",child:r,subject:i,session_id:t.child});let s=Date.now(),o=1;try{o=await be(e.run)(t.offer.key,{yes:!0,mode:"override",resume:t.child,onChildEvent:a=>{Dr.has(a.type)||e.emit(Ee(a,{verb:"design",id:t.child}))}})}finally{o===3&&e.stopped()||e.review.offerEnded?.(t.proposalId,t.card,"ran");let a=o===0&&le(e.store,t.child,null);e.emit({type:"child_end",child:r,ok:a,dur_s:Math.max(1,Math.round((Date.now()-s)/1e3)),exit_code:o,...!a&&!e.stopped()?{next:[r==="evolve"?{cmd:`kane-cli maintain evolve ${i} --mode agent`,why:"update its tests later"}:{cmd:`kane-cli design tests --use-case ${i} --mode agent`,why:"designs its tests again later"}]}:{}})}if(e.stopped())return!0}return!1}function Or(e,t){return[{cmd:`kane-cli context extract --resume ${e} --mode agent${t.map(n=>` --answer ${n}=approve`).join("")}`,why:"answer each change: approve, reject or defer"}]}var ws=["approve","reject","defer"];function mt(e){let t=e.filter(n=>/^q\d+=/i.test(n.trim()));return{questions:t,cards:e.filter(n=>!t.includes(n))}}function Ar(e,t){let n=i=>({kind:"refuse",code:"STRUCTURED_TARGET_UNKNOWN",error:i}),r=[];for(let i of e){let s=i.indexOf("="),o=(s>0?i.slice(0,s):i).trim().toLowerCase(),a=(s>0?i.slice(s+1):"").trim().toLowerCase();if(!t.includes(o))return n(`error: --answer ${o} names no card in this review; its cards are ${t.join(", ")}`);if(!ws.includes(a))return n(`error: --answer ${i.trim()} isn't a verdict; a card takes approve, reject or defer`);if(r.some(c=>c.key===o))return n(`error: --answer ${o} is given twice; answer each card once`);r.push({key:o,verdict:a})}return{kind:"apply",verdicts:r}}async function We(e){let t=0,n=new Map(e.items.map(r=>[e.keys.get(r.key)??r.key,r]));for(let{key:r,verdict:i}of e.verdicts){if(e.stopped?.())return{failedChildren:t};let s=n.get(r);if(!s)continue;let o;try{o=await e.review.applyVerdict(s.key,i)}catch(g){let f=g.code==="CONCURRENT_APPEND"?"CONCURRENT_APPEND":"CONNECTION_FAILED";e.emit({type:"card_refused",source:e.words.source,key:r,verdict:i,code:f,refusal:f==="CONCURRENT_APPEND"?G.refused(s.card,f,e.words).line:G.notLanded});continue}if(!o.ok){e.emit({type:"card_refused",source:e.words.source,key:r,verdict:i,code:o.code,refusal:G.refused(s.card,o.code,e.words).line});continue}let a=G.receipt(s.card,i),c=o.offer?e.onApproved?.(s,o.offer):void 0;e.emit({type:"card_verdict",source:e.words.source,key:r,verdict:i,line:a.line,...a.note?{note:a.note}:{},...c?.offer?{offer:c.offer}:{}});let u=await c?.run?.();u&&!u.ok&&(t++,e.emit({type:"error",code:"DESIGN_CHILD_FAILED",key:r,use_case:u.useCase,message:`the redesign of ${u.useCase} failed: ${u.error}`}))}return{failedChildren:t}}async function Pr(e){let t=s=>e.keys.get(s.key)??s.key,n=e.items.filter(s=>s.card.kind==="ARCHIVE"),{failedChildren:r}=await We({review:e.review,items:e.items,keys:e.keys,verdicts:e.items.map(s=>({key:t(s),verdict:s.card.kind==="ARCHIVE"?"defer":"approve"})),emit:e.emit,words:e.words,...e.onApproved?{onApproved:e.onApproved}:{},...e.stopped?{stopped:e.stopped}:{}});if(n.length>0&&e.emit({type:"reconcile_held",source_id:e.words.source,held:n.map(s=>({ref:t(s),why:s.card.why||s.card.title}))}),e.stopped?.())return{failed:r};let i=e.loadCards();if(i.length===0)return{failed:r};await We({review:e.review,items:i,keys:e.keys,verdicts:i.map(s=>({key:t(s),verdict:"defer"})),emit:e.emit,words:e.words});for(let s of i)e.emit({type:"error",code:"OVERRIDE_UNDECIDED",key:t(s),message:`the review couldn't decide card ${t(s)} (${s.card.title}) itself: it is left deferred, and the others went on`});return{failed:i.length+r}}function bs(e,t){let n=new Set;for(let r=t;r&&!n.has(r);r=e.superseded.get(r)){if(e.trust.get(r)==="archived")return!0;n.add(r)}return!1}function $r(e,t){let n=new Set(t),r=[...new Set(t.filter(s=>!bs(e,s)).map(s=>e.tipOf(s)))].filter(s=>n.has(s)&&e.hasNode(s));if(r.length===0)return null;let i=r.map(s=>{let o=e.getNode(s).content,a=e.displayNameOf(s);return{temp_ref:s,...a?{logical_id:a}:{},title:String(o.title??""),risk:String(o.risk??""),...typeof o.description=="string"?{description:o.description}:{}}});return{headline:qe.text("chat.added_use_cases",{minted:i.length,matched:0}),items:i}}var b=Ss;Rt(b.supportId);kn(b.traceVerb);var Z=ks,O=e=>Z.postMessage(e);Et(yr(qe,new Map((b.ingest??[]).flatMap(e=>e.remote?[[e.sourceId,hn({provider:e.remote.provider,display:e.remote.display,...e.remote.title!==void 0?{title:e.remote.title}:{}})]]:[]))),(e,t)=>O({type:"event",event:{type:"warning",message:e.replace(/^warning:\s*/,""),...t?{code:t}:{}}}),()=>b.supportId);var Cs=/^error: (agent failed|repair run failed|agent ended)/,jr=e=>b.run.resume===void 0?e:{...e,out:t=>en(t)?O({type:"log",line:t}):e.out(t)},pe=e=>O({type:"log",line:e});async function xs(){if(b.testing?.agent){let{standIn:t}=await import(b.testing.agent.module);return t(b.testing.agent.name)}let{runAgent:e}=await import("./bridge-2UHJOVLX.js");return{agent:e}}function Mr(e){try{return structuredClone(e)}catch{return JSON.parse(JSON.stringify(e))}}function Lr(e){let t={};(e.state.pending?.questions??[]).forEach((i,s)=>t[s]=[...e.multiSelection(s)]);let n=new Set;for(let i of e.state.turns)for(let s of i.items??[])n.add(s.temp_ref);for(let i of e.state.activeTurn?.items??[])n.add(i.temp_ref);let r={};for(let i of n){let s=e.aliasOf(i);s!==void 0&&(r[i]=s)}return{multi:t,canIngest:!1,senderAlive:e.senderAlive(),aliases:r}}function _s(e,t){let{baseHash:n}=t.call(I.scope,null);return()=>e.recordsSince(e.parse(n)).flatMap(r=>r.nodes.filter(i=>i.label==="usecase").map(i=>i.cid))}function Rs(e,t){let n=_s(e,t);return{addedBefore:n,checkIn:()=>$r(se(e).graph(),n())}}async function bt(e,t){let{buildExtractChat:n}=await import("./extract-chat-VPYDGQKO.js"),r=null,i=()=>{r&&O({type:"mirror",state:Mr(r.state),view:Lr(r)})},s=await n({site:se(e),store:e,credentials:re,agent:H.agent,auth:Y.auth,preflight:Y.preflightTurn,onRender:i,...Y.probe?{probe:Y.probe}:{},matchUnreviewed:!0,...t?{addedBefore:t.addedBefore,resumedCheckIn:t.checkIn}:{}});return r=s.controller,i(),Z.on("message",o=>{if(o.type!=="controller")return;if(o.member==="approveAdded"){Promise.resolve(s.controller.approveAdded()).then(c=>O({type:"approved",go:c}),()=>O({type:"approved",go:!1}));return}let a=s.controller[o.member];typeof a=="function"&&Promise.resolve(a.apply(s.controller,o.args)).catch(()=>{})}),s}async function Es(e,t,n,r,i){let s=await bt(t,i),o=i?e:{...e,sessionId:b.sessionId},a=i?[...i.addedBefore()]:null;return $n(o,{...jr(s.runDeps({isTTY:!0,onSummary:r,telemetry:de})),emit:n,note:pe,...a?{addedBefore:()=>a}:{}})}function Ge(e){return new Promise(t=>{let n=r=>{r.type==="preMountAnswer"&&(Z.off("message",n),t(r.answer))};Z.on("message",n),O({type:"preMount",question:e})})}async function Br(e,t,n){if(!e.useCase)return null;let r=e.useCase,[{designEntryGate:i},{designGate:s},{phaseLadderFor:o},{liveUseCase:a}]=await Promise.all([import("./trust-gate-674C2NZS.js"),import("./gate-NB5CJMTN.js"),import("./phase-seed-ZZSJME7M.js"),import("./use-case-ref-44BPIP4N.js")]),c=b.mode==="agent",u=se(t).graph(),g=async(R,d)=>{if(O({type:"unstarted"}),!c)return await Ge({kind:"refused",message:R.message,...R.next?{next:R.next.cmd?`${R.next.lead} ${R.next.cmd}`:R.next.lead}:{}}),2;let v=R.next?.cmd,k=v===void 0?void 0:d==="error"?[{cmd:v,why:R.next.why??R.next.lead}]:[{cmd:v,why:R.next.why??R.next.lead,title:"Redesign"},...R.more??[]];return n({type:d,...R.code?{code:R.code}:{},message:R.message,final:!0,...k?{next:k}:{}}),2},f=a(u,r);if(!f.ok){if(f.why==="unknown"){let R=[...u.names.keys()].filter(d=>d.startsWith("uc-")).sort().slice(0,6);return g(ne.unknown(r,b.projectName,R),"gate_refused")}return g(f.why==="removed"?ne.removed(r,b.projectName):ne.notUseCase(r,f.label),"gate_refused")}let p=u.getNode(f.cid)?.content?.title,l=typeof p=="string"&&p.trim()!==""?p:void 0,m;try{m=e.resume?t.sessions().peek(e.resume)?.use_case:void 0}catch{m=void 0}let _=i(u,{useCase:r,resuming:!!e.resume,sessionUseCase:m});if(_?.code==="UC_ARCHIVED")return g(ne.archived(l,r,b.projectName),"error");if(_?.code==="UC_UNREVIEWED"&&!e.allowUnreviewed)return g(ne.unapproved(l,r,c),"error");if(!c||e.resume)return null;let w=e.phase!==void 0&&o(t,u,r).length>0,S=s(u,r,!!e.force||w);return S.ok||!S.wall?null:g(ne.designed(l,r,S.wall.kind==="designed-stale"),"gate_refused")}async function Ds(e,t,n,r){let[{buildDesignChat:i},{runDesign:s,askedRedesign:o},{designGate:a},{captureForceScope:c}]=await Promise.all([import("./design-chat-YUI2JPO6.js"),import("./run-CSYGVV3D.js"),import("./gate-NB5CJMTN.js"),import("./design-committer-7YIPFKMO.js")]),u=se(t),g=await Br(e,t,n);if(g!==null)return g;let f=e;if(!e.resume&&e.useCase&&!e.phase){let w=u.graph(),S=a(w,e.useCase,!!e.force);if(!S.ok&&S.wall){let R=w.resolve(e.useCase)?.tip,d=R!==void 0?w.getNode(R)?.content?.title:void 0,v=await Ge({kind:"design-entry",wall:S.wall.kind,...typeof d=="string"&&d.trim()!==""?{title:d}:{},display:S.wall.display,testsReplaced:c(w,e.useCase).filter(k=>w.getNode(k)?.label==="test").length,sessionId:b.sessionId});if(!v.go)return v.code;f=v.because?o(f,v.because):{...f,...v.force?{force:!0}:{}}}}let p=await i({site:u,store:t,credentials:re,agent:H.agent,auth:Y.auth,preflight:Y.preflightTurn,...f.useCase?{useCase:f.useCase}:{},testFilesAt:"save"}),{controller:l}=p,m=()=>O({type:"mirror",state:Mr(l.state),view:Lr(l)});l.subscribe(m),m(),Z.on("message",w=>{if(w.type!=="controller")return;let S=l[w.member];typeof S=="function"&&Promise.resolve(S.apply(l,w.args)).catch(()=>{})});let _=async w=>(await Ge({kind:"retarget",message:Xt(w)})).go;return s({...jn(t,f),...b.fresh?{sessionId:b.sessionId}:{},confirmRetarget:_},{...jr(p.runDeps({isTTY:!0,onSummary:r,telemetry:de})),emit:n,note:pe})}function Is(e,t){try{let n=se(e).graph(),r=t.filter(s=>{let o=n.resolve(s);return o!==null&&n.getNode(o.tip)?.label==="test"}).length,i=Cn({graph:n,ids:t,cwd:b.projectDir});if(i.variables.length===0&&i.noStartPage.length===0)return;try{xn(i,b.projectDir)}catch(s){O({type:"log",line:`the variables the designed tests need couldn't be written to ${i.file}: ${ot(s)}`})}O({type:"needed",needed:i,tests:r})}catch(n){O({type:"log",line:`the designed tests' needs couldn't be read: ${ot(n)}`})}}var kt=Symbol("ready to write"),Fr=e=>new Proxy(e,{get:(t,n,r)=>n==="putBlob"?()=>{throw kt}:Reflect.get(t,n,r)});function Nr(e){let t=new Map;return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,i=>(t.has(n)||t.set(n,r(i)),t.get(n))]))}function Ur(e){let t=e instanceof Error?e.message:String(e),n=e?.code;return{code:typeof n=="string"?n:/^([A-Z][A-Z0-9_]+):\s*/.exec(t)?.[1]??/\s*\[([A-Z][A-Z0-9_]+)\]$/.exec(t)?.[1]??"INGEST_FAILED",message:t.replace(/^[A-Z][A-Z0-9_]+:\s*/,"").replace(/\s*\[[A-Z][A-Z0-9_]+\]$/,"")}}var qr=(b.ingest??[]).map(e=>e.fingerprint).filter(e=>typeof e=="string"&&e!=="");function Os(e){return new Promise(t=>{let n=r=>{r.type!=="ingestUploaded"||r.index!==e||(Z.off("message",n),r.ok&&r.fingerprint!==void 0&&qr.push(r.fingerprint),t(r.ok))};Z.on("message",n)})}function ht(e){return new Promise(t=>{let n=r=>{r.type!=="ingestGo"||r.index!==e||(Z.off("message",n),t(r.go))};Z.on("message",n)})}async function As(){if(b.testing?.remoteDeps){let e=await import(b.testing.remoteDeps.module);return{credentials:re,...e.remoteDepsFor(b.testing.remoteDeps.name)}}return{credentials:re}}async function Ps(e,t){let n=ln().byId(t.plugin.id);if(n===void 0)return{outcome:{outcome:"refused",code:"PLUGIN_MISSING",message:`${t.file} is read by plugin ${t.plugin.id}, which this build does not include`}};let r=un(),i={plugin:n,ref:t.plugin.ref,named:t.plugin.named,isFile:t.plugin.isFile,asId:t.sourceId},s=t.plugin.isFile?{bytes:t.bytes}:void 0,o=a=>tt({...i,store:a,supplied:s});try{return{outcome:{outcome:(await tt({...i,store:Fr(e),...s?{supplied:s}:{...r?{connect:r}:{},onFetched:c=>s=c}})).status==="unchanged"?"unchanged":"created"}}}catch(a){if(a instanceof cn){let{code:c,message:u,remedy:g}=a.refusal;return{outcome:{outcome:"refused",code:c,message:u,...g?{facts:{remedy:g}}:{}}}}return a!==kt?{outcome:{outcome:"refused",...Ur(a)}}:{outcome:{outcome:"created"},pluginWrite:o,...t.plugin.isFile?{}:{fetched:s.bytes}}}}async function $s(e,t,n){if(t.plugin)return Ps(e,t);let r=Buffer.from(t.bytes),i,s=t.file,o;if(t.remote){let a=dn(t.remote.provider),c=an(t.remote.mediaType);if(!a?.prepare||!c)return{outcome:{outcome:"refused",code:"UNSUPPORTED_MEDIA",message:`${t.file} can't be added`}};let u={provider:t.remote.provider,sourceId:t.sourceId,bytes:r,media:c,label:t.remote.label,display:t.remote.display,...t.remote.title!==void 0?{title:t.remote.title}:{},origin:t.remote.origin,identity:t.remote.identity,warnings:[],...t.remote.downloads?{downloads:t.remote.downloads}:{}},g=await a.prepare(u,e,await n());if(!g.ok){let{code:f,message:p,facts:l}=g.failure;return{outcome:{outcome:"refused",code:f,message:p,...l?{facts:l}:{}}}}({media:i,label:s}=g),o=Nr(g.converters)}else{let a=on(t.file);if(!a.ok)return{outcome:{outcome:"refused",code:a.code,message:`${t.file} is a file type kane can't ingest`}};i=a.media,o=Nr({pdf:rn,docx:sn})}try{return{outcome:{outcome:(await et({store:Fr(e),bytes:r,media:i,sourceId:t.sourceId,label:s,converters:o})).status==="unchanged"?"unchanged":"created"},write:{bytes:r,media:i,label:s,converters:o}}}catch(a){return a===kt?{outcome:{outcome:"created"},write:{bytes:r,media:i,label:s,converters:o}}:{outcome:{outcome:"refused",...Ur(a)}}}}async function Ns(e,t,n){let r=null,i=()=>r??=As(),s=[];for(let c of t)s.push(await $s(e,c,i));let o=s.findIndex(c=>c.outcome.outcome==="refused");if(o>=0)return O({type:"ingestOutcome",index:o,...s[o].outcome}),await ht(o),2;if(t.length>1){let c=$(e),u=s.flatMap((g,f)=>g.outcome.outcome==="created"&&c.heads.get(t[f].sourceId)!=null?[f]:[]);if(u.length>0)return O({type:"ingestOutcome",index:u[0],outcome:"refused",code:"NEW_VERSION_ALONE",message:"a new version is reviewed on its own",facts:{newVersions:u.join(",")}}),await ht(u[0]),2}for(let[c,u]of s.entries())if(u.fetched!==void 0&&(O({type:"ingestFetched",index:c,bytes:u.fetched}),!await Os(c)))return 2;for(let[c,u]of s.entries())if(O({type:"ingestOutcome",index:c,...u.outcome}),!await ht(c))return 2;let a=null;for(let[c,u]of t.entries()){let g=s[c],f=u.plugin!==void 0&&!u.plugin.isFile,p=f?Tr(e,u.sourceId):null,l=g.outcome.outcome==="refused"?"unchanged":g.outcome.outcome,m=[],_=null,w,S=null;if(g.outcome.outcome==="created"&&(g.write||g.pluginWrite))try{let k=g.pluginWrite?await g.pluginWrite(e):await et({store:e,sourceId:u.sourceId,...g.write});if(l=k.status,m=k.warnings??[],k.status==="created"&&(w=Ts(e,u.sourceId,k.blob)),k.composite){let{kind:x,pages:P,delivered:K,omitted:F}=k.composite;_={kind:x,...P!==void 0?{pages:P}:{},delivered:K,omitted:F},u.remote&&K+F>0&&(S={delivered:K,omitted:F})}}catch(k){return O({type:"log",line:`the source wasn't written after its result was taken: ${k instanceof Error&&k.stack?k.stack:String(k)}`}),O({type:"ingestUnwritten",index:c}),2}let R=b.verb==="reconcile"&&l==="unchanged"?En(e,u.sourceId):null,d=R?.behind.length??0,v=R?.unread===!0;u.then==="review"&&(a={status:l,behind:d,unread:v}),n({type:"ingested",source_id:u.sourceId,status:l,...d>0?{behind:d}:{},...v?{unread:!0}:{},...f?{cursor:{from:p,to:Tr(e,u.sourceId)}}:{},...m.length>0?{warnings:m}:{},..._?{media:_}:{},...w?{duplicate_of:w}:{},...u.remote?{origin:u.remote.origin}:{}}),O({type:"ingested",index:c,status:l,...d>0?{behind:d}:{},...v?{unread:!0}:{},...w?{duplicateOf:w}:{},...S?{attachments:S}:{}})}return t[0]?.then==="review"&&a!==null&&a.status==="unchanged"&&a.behind===0&&!a.unread||t[0]?.then==="pause"?0:null}function Tr(e,t){let n=$(e),r=n.heads.get(t);return typeof r=="string"?n.mediaOf(r).plugin?.fetch?.cursor??null:null}function Ts(e,t,n){let r=$(e);for(let[i,s]of r.heads.entries())if(i!==t&&s!=null&&r.getNode(s)?.content.blob===n)return i}var St=()=>b.ingest?.[0]?.sourceId??b.review.sourceId,js=()=>b.ingest?.[0]?.file??b.review?.file??"<file>",yt=e=>{let t=St(),n=b.ingest?.[0]?.remote,r=b.review?.page,i;if(n)i=vn({...n,address:n.origin.url},je(n.provider,n.origin.url,t));else if(r){let s=Te(r.address)?.name??"web";i=wn(s,r.address,yn(e,t),r.as)}return{source:t,file:js(),...i?{page:i}:{}}},Hr=e=>e.pending()===null&&(e.givenVerdicts?.().length??0)>0,wt=e=>b.run.resume!==void 0&&(e.pending()?.kind==="cards"||Hr(e));function ke(e,t){return{store:e,projectDir:null,agent:t.agent,credentials:re,...t.auth?{auth:t.auth}:{},...t.preflightTurn?{preflightTurn:t.preflightTurn}:{},testFilesAt:"save",note:pe,telemetry:de,tracePath:Me}}var Ms=new Set(["reasoning_delta","reasoning_done","tool_activity","decision_activity","usage","text_delta","progress"]);async function Ls(e,t,n,r){let i=St(),s=yt(e),o=mn(s);O({type:"reviewMirror",review:{pending:null,cards:[],lastReadError:null,given:[],named:s}});let c=(await bt(e)).controller,u=null,g=pt({store:e,note:d=>O({type:"log",line:`review: ${d}`}),children:t,sessionId:b.sessionId,by:{kind:"human",id:"owner"},agent:n,telemetry:de,ask:d=>c.ask(d),narrate:d=>{d.type==="proposal"?u=d.narrative??null:Ms.has(d.type)&&c.onAgentEvent(d)},emit:r});if(b.run.resume!==void 0){let d=Sr(e,t.ids(),new Set((g.resumableChildren?.()??[]).map(v=>v.child)),v=>O({type:"log",line:v}));d.own+d.carried>0&&c.creditsSoFar?.(d.own+d.carried,d.carried)}let f={again:0,added:0},p=async(d,v)=>{let k=await xr({review:g,store:e,children:t,parent:c,run:ke(e,n),card:d,answer:v,designed:f,log:x=>O({type:"log",line:x})});return k.code===0&&(f[k.verb==="evolve"?"again":"added"]+=k.tests),k.code===3&&c.state.status==="pausing"&&(m.push({type:"pause"}),_?.()),k},l,m=[],_=null,w=c.attachSender(d=>{m.push(d),_?.()}),S=async()=>{for(;m.length===0;)await new Promise(d=>_=d);return m.shift()},R=async d=>{c.setWorking?.(`Reading ${s.page?.reading??i}\u2026`);let v=await d(),k=g.loadCards();return l.mirror(),c.setWorking?.(null),c.narrated?.(u,k.length>0?{kind:"commit",ok:!0,held:!0,line:G.held(o,k.map(x=>x.card.kind))}:void 0),u=null,v};l=bn({...g,loadCards:()=>kr(g.loadCards(),e,i,o),offer:p,...g.steer?{steer:d=>R(()=>g.steer(d))}:{}},O,d=>O({type:"log",line:d}),s,b.run.resume!==void 0?()=>Cr(g,e):void 0),c.ledger({kind:"header",text:G.header(o),tail:""}),Z.on("message",d=>{d.type==="review"&&l.serve(d)});try{if(!wt(g)){let d=await R(()=>g.startReview(i));if(d!==3)return d!==0&&H.interrupted()?3:d}for(;;){let d=await S();if(d.type==="session_complete")return 0;if(d.type==="pause")return 3;d.type==="user_message"&&d.text&&g.steer&&await R(()=>g.steer(d.text))}}finally{w()}}async function Bs(e,t,n,r){let i=St(),s=b.run.override===!0?Dn(e):new Set,o=[],a=null,c=pt({store:e,note:w=>O({type:"log",line:`review: ${w}`}),children:t,sessionId:b.sessionId,by:{kind:"human",id:"owner"},agent:r,telemetry:de,emit:w=>{if(w.type==="review_cards")return void(o=w.dropped);if(!(w.type==="card_verdict"||w.type==="card_refused")){if(w.type==="review_resolved")return void(a=w);w.child_id!==void 0&&(w.type==="session_paused"||w.type==="session_complete")||n(w)}}});n({type:"run_start"});let u=me("extract",b.sessionId,!0),g=w=>n({type:"session_paused",sid:b.sessionId,source_id:i,mode:"agent",resume:u,expires_at:null,pending_questions:[],next:[{cmd:u,why:"resume"}],...w});if(b.run.resume!==void 0&&await Ir({review:c,store:e,run:ke(e,r),emit:n,stopped:H.interrupted}))return g({}),3;if(wt(c)&&Hr(c))return 0;if(!wt(c)){let w=await c.startReview(i);if(w!==3)return w!==0&&H.interrupted()?(g({}),3):w}let f=c.loadCards(),p=$(e),l=wr(f,Er(e,t)??f.filter(w=>w.card.kind==="ADD").map(w=>w.key),p);if(f=He(f,l),b.run.override===!0){let w=ke(e,r),S=b.testing?.refuseCard,R=S?Object.assign(Object.create(c),{applyVerdict:async(v,k,x)=>v===S||l.get(v)===S?{ok:!1,code:"CONCURRENT_APPEND",refusal:"the store moved under the review (test)"}:c.applyVerdict(v,k,x)}):c,d=await Pr({review:R,items:f,keys:l,emit:n,words:yt(e),loadCards:()=>He(c.loadCards(),l),onApproved:(v,k)=>gt({review:c,store:e,children:t,run:w,emit:n,card:v.key,key:l.get(v.key)??v.key,offer:k,title:rt(v.card),stopped:H.interrupted}),stopped:H.interrupted});return a&&n(a),n({type:"reconcile_use_cases",source_id:i,use_cases:In(e,i,s)}),d.failed>0&&O({type:"itemsFailed",count:d.failed}),H.interrupted()?(g({}),3):0}let m=mt(b.run.answer??[]).cards;if(m.length>0){let w=Ar(m,f.map(d=>l.get(d.key)??d.key));if(w.kind==="refuse")return n({type:"error",message:w.error,code:w.code}),2;let S=ke(e,r),R=await We({review:c,items:f,keys:l,verdicts:w.verdicts,emit:n,words:yt(e),onApproved:(d,v)=>gt({review:c,store:e,children:t,run:S,emit:n,card:d.key,key:l.get(d.key)??d.key,offer:v,title:rt(d.card),stopped:H.interrupted}),stopped:H.interrupted});if(a&&n(a),R.failedChildren>0&&O({type:"itemsFailed",count:R.failedChildren}),f=He(c.loadCards(),l),f.length===0&&H.interrupted())return(c.resumableChildren?.()??[]).length>0?(g({}),3):(g({reason:"review_decided",pending_cards:[],next:[{cmd:me("extract",b.sessionId,!0),why:"finish the review"}]}),3);if(f.length===0)return 0}n({type:"review_cards",source:i,cards:br(f,l,p),dropped:o});let _=f.map(w=>l.get(w.key)??w.key);return g({reason:"review_pending",pending_cards:_,next:Or(b.sessionId,_)}),3}var Ke,vt=new Set,Wr=await xs(),de=$t(gr(b)),H=Fn(Wr.agent,()=>{},null),Y={auth:{...b.auth,...de.spawnEnv()},...Wr,preflightTurn:async()=>b.preflight,telemetry:de,agent:H.agent},Gr=!1,Fs=()=>H.interrupted()||Gr;Z.on("message",e=>{e.type==="stop"&&H.interrupt(),e.type==="kill"&&H.kill(),e.type==="controller"&&e.member==="requestPause"&&(Gr=!0)});try{await hr(b);let e=new zt(b.bridge,45e4),t=b.lastEventSeq,n=Ue(e),r=rr(e,{sessionId:b.sessionId,sideDir:b.sideDir,children:n,lastEventSeq:()=>t,log:x=>O({type:"log",line:x}),knownBlobs:qr}),i=x=>{t+=1,O({type:"sessionEvent",seq:t,kind:x.type,payload:x})},s=x=>{if(!(H.interrupted()&&x.type==="error"&&Cs.test(String(x.message??"")))){if(x.type==="commit")for(let P of x.minted??[])typeof P.logical_id=="string"&&vt.add(P.logical_id);t+=1,O({type:"sessionEvent",seq:t,kind:x.type,payload:x}),O({type:"event",event:x})}},{run:o}=b,a=b.landed??[],c=b.verb==="extract"&&o.resume!==void 0&&a.length>0&&e.call(I.stateGet,{})===null,u=b.fresh||c,g=[...new Set((b.ingest??[]).map(x=>x.sourceId))],f=g.length>1?g:c?a:[],p=b.verb==="reconcile"?mt(o.answer??[]).questions:b.verb==="evolve"?[]:o.answer??[],l=p.length?nn({opts:{resume:o.resume,answer:p},reader:r.sessions(),verb:b.verb==="design"?"design":"extract"}):{kind:"none"};if(l.kind==="apply"){let x=P=>b.verb==="design"?s({type:"note",text:P}):pe(P);for(let P of l.notes)x(P);l.matchedQids.length>0&&x(`applying ${l.matchedQids.length} structured answer(s) from --answer to the paused session's pending questions`);for(let P of l.matchedQids)s({type:"panel_resolved",id:P,by:"user",via:"flag"})}let m=l.kind==="apply"&&l.statement?[o.message,l.statement].filter(Boolean).join(`
11
11
 
12
12
  `):o.message,_=l.kind==="refuse"?(s({type:"error",message:l.error,code:l.code}),2):null,w=o.override?"override":b.mode,S=o.override?x=>O({type:"out",line:x}):()=>{},R={mode:w,...f.length>1?{sources:f}:f.length===1?{source:f[0]}:o.source!==void 0?{source:o.source}:{},...o.resume!==void 0&&!c?{resume:o.resume}:{},...m!==void 0?{message:m}:{},...o.force!==void 0?{force:o.force}:{},...o.trust!==void 0?{trust:o.trust}:{},remainderSession:x=>n.register(x)},d=x=>O({type:"summary",facts:x}),v={mode:w,...o.useCase!==void 0?{useCase:o.useCase}:{},...o.resume!==void 0?{resume:o.resume}:{},...m!==void 0?{message:m}:{},...o.force!==void 0?{force:o.force}:{},...o.allowUnreviewed!==void 0?{allowUnreviewed:o.allowUnreviewed}:{},...o.phase!==void 0?{phase:o.phase}:{},...o.plan!==void 0?{plan:o.plan}:{},...o.max!==void 0?{max:o.max}:{},...o.strength!==void 0?{strength:o.strength}:{}},k=b.ingest?await Ns(r,b.ingest,s):null;Ke=_!==null?_:k!==null?k:b.verb==="evolve"&&b.mode==="agent"?await(async()=>{let x=await cr({store:r,children:n,emit:s,logEvent:i,log:pe,childRun:ke(r,Y),run:o,sessionId:b.sessionId,projectName:b.projectName,origins:b.origins??{},stopped:H.interrupted});return x.unstarted&&O({type:"unstarted"}),x.notUpdated&&O({type:"notUpdated",useCases:x.notUpdated}),x.code})():b.verb==="evolve"?await(async()=>{let x=await fr({store:r,children:n,logEvent:i,log:pe,childRun:ke(r,Y),run:o,projectName:b.projectName,origins:b.origins??{},stopped:Fs,askMain:Ge,mountChat:()=>bt(r),notUpdated:(P,K,F)=>O({type:"notUpdated",useCases:P,titles:K,stillStale:F})});return x.unstarted&&O({type:"unstarted"}),x.code})():b.verb==="reconcile"&&b.mode==="interactive"?await Ls(r,n,Y,i):b.verb==="reconcile"?await Bs(r,n,s,Y):b.verb==="design"&&b.mode==="interactive"?await Ds(v,r,s,d):b.verb==="design"?await Br(v,r,s)??await Un({...v,...b.fresh?{sessionId:b.sessionId}:{}},se(r),{emit:s,out:S,progress:()=>{},channel:!0},{...Y,testFilesAt:"save"}):b.mode==="agent"?await qn(R,se(r),{...u?{sid:b.sessionId}:{},emit:s,out:S,note:pe,progress:()=>{},onSummary:d,channel:!0},{...Y,matchUnreviewed:!0}):await Es(R,r,s,d,u?void 0:Rs(r,e)),b.verb==="design"&&vt.size>0&&Is(r,[...vt])}catch(e){O({type:"log",line:e instanceof Error&&e.stack?e.stack:String(e)}),O({type:"event",event:{type:"error",message:tn.runStopped(b.verb)}}),Ke=1}finally{H.dispose()}await de.end({exit_code:Ke});O({type:"done",code:Ke});
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q}from"./chunk-HHW6MRU3.js";import"./chunk-7DFBOVUB.js";import"./chunk-4I7YN6YY.js";import"./chunk-UR6MHSHU.js";export{a as SESSION_PATCH_KEYS,g as SID_RE,b as SessionError,c as TTL_MS,q as cleanSessions,l as createSession,d as expiryOf,h as givenSessionIdRefusal,o as listSessions,j as newSessionState,n as peekSession,k as renewedSessionState,m as resumeSession,e as sessionExpired,f as sessionExpiry,i as sessionHandle,p as sessionListRows};
2
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q}from"./chunk-G4K3TP2I.js";import"./chunk-YJAQZMJT.js";import"./chunk-HYJVYYAZ.js";import"./chunk-UR6MHSHU.js";export{a as SESSION_PATCH_KEYS,g as SID_RE,b as SessionError,c as TTL_MS,q as cleanSessions,l as createSession,d as expiryOf,h as givenSessionIdRefusal,o as listSessions,j as newSessionState,n as peekSession,k as renewedSessionState,m as resumeSession,e as sessionExpired,f as sessionExpiry,i as sessionHandle,p as sessionListRows};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as $}from"./chunk-RX6776AI.js";import{a as w}from"./chunk-R7KXAISS.js";import"./chunk-WMGKUERB.js";import"./chunk-WOSANGV6.js";import{a as g}from"./chunk-73Y6T2UK.js";import{e as h}from"./chunk-35ECWCCK.js";import"./chunk-BWXLZS5O.js";import"./chunk-63EKRZKI.js";import"./chunk-3JLEDSG5.js";import"./chunk-42PALMW2.js";import"./chunk-EZN7CF45.js";import"./chunk-7XBNMOH4.js";import"./chunk-ZCIWQHCO.js";import"./chunk-ZFM77AQU.js";import"./chunk-22PIMG52.js";import"./chunk-UEE3RZN4.js";import"./chunk-DBMW3VUN.js";import"./chunk-KU3YHPWZ.js";import"./chunk-6NFOH4AC.js";import"./chunk-7V4BQSSV.js";import{n as p,o as m,q as f}from"./chunk-HHW6MRU3.js";import"./chunk-7DFBOVUB.js";import"./chunk-4I7YN6YY.js";import"./chunk-UR6MHSHU.js";function b(t,n=new Date){let o=new Date(t).getTime()-n.getTime();if(Number.isNaN(o))return"unknown";if(o<=0)return"EXPIRED";let e=Math.floor(o/36e5),i=Math.round(o%36e5/6e4);return e>0?`${e}h ${i}m`:`${i}m`}function l(t){return t.verb==="design"?`kane-cli design tests --resume ${t.sid} --mode ${t.mode==="agent"?"agent":"interactive"}`:t.verb===void 0||t.verb==="extract"?`kane-cli context extract --resume ${t.sid}${t.mode==="agent"?" --mode agent":""}`:null}var k="kane-cli maintain reconcile --apply";function S(t,n){try{return w(t).proposals().verdicts(n).resolved===!0}catch{return!1}}function x(t){return t.verb==="design"?t.use_case??"?":t.verb===void 0||t.verb==="extract"?"extract corpus":`${t.verb} session`}function j(t,n,o){let e,i,s;try{if(e=p(t,n),!e)return process.stderr.write(`error: no session ${n} (kane-cli context sessions lists them)
2
+ import{b as $}from"./chunk-JTNEF5ZP.js";import{a as w}from"./chunk-HVOXMCKE.js";import"./chunk-WMGKUERB.js";import"./chunk-UWPG5MWM.js";import{a as g}from"./chunk-73Y6T2UK.js";import{e as h}from"./chunk-DXIQVBMI.js";import"./chunk-BWXLZS5O.js";import"./chunk-63EKRZKI.js";import"./chunk-3JLEDSG5.js";import"./chunk-ZHAMVLQZ.js";import"./chunk-GJXO6FF7.js";import"./chunk-LLQWEGXD.js";import"./chunk-ZCIWQHCO.js";import"./chunk-CQDCNP7V.js";import"./chunk-22PIMG52.js";import"./chunk-PI7OXS62.js";import"./chunk-DBMW3VUN.js";import"./chunk-KU3YHPWZ.js";import"./chunk-7V4BQSSV.js";import"./chunk-ZAQGIC33.js";import{n as p,o as m,q as f}from"./chunk-G4K3TP2I.js";import"./chunk-YJAQZMJT.js";import"./chunk-HYJVYYAZ.js";import"./chunk-UR6MHSHU.js";function b(t,n=new Date){let o=new Date(t).getTime()-n.getTime();if(Number.isNaN(o))return"unknown";if(o<=0)return"EXPIRED";let e=Math.floor(o/36e5),i=Math.round(o%36e5/6e4);return e>0?`${e}h ${i}m`:`${i}m`}function l(t){return t.verb==="design"?`kane-cli design tests --resume ${t.sid} --mode ${t.mode==="agent"?"agent":"interactive"}`:t.verb===void 0||t.verb==="extract"?`kane-cli context extract --resume ${t.sid}${t.mode==="agent"?" --mode agent":""}`:null}var k="kane-cli maintain reconcile --apply";function S(t,n){try{return w(t).proposals().verdicts(n).resolved===!0}catch{return!1}}function x(t){return t.verb==="design"?t.use_case??"?":t.verb===void 0||t.verb==="extract"?"extract corpus":`${t.verb} session`}function j(t,n,o){let e,i,s;try{if(e=p(t,n),!e)return process.stderr.write(`error: no session ${n} (kane-cli context sessions lists them)
3
3
  `),2;i=e.pending.questions.map(h),s=l(e)}catch{return process.stderr.write(`error: session ${n} has a corrupt state.json \u2014 remove with: kane-cli context sessions clean ${n}
4
4
  `),2}let r=new Date(e.expires_at).getTime()<=Date.now(),c=e.reconcile?.proposal_id&&!S(t,e.reconcile.proposal_id)?{cmd:k,needs:"tty"}:null;if(o)return process.stdout.write(JSON.stringify({sid:e.sid,verb:e.verb??"extract",use_case:e.use_case,mode:e.mode,created_at:e.created_at,expires_at:e.expires_at,...r?{expired:!0}:c?{held_review:c}:s!==null?{resume:s}:{},pending_questions:i,pending_proposals:e.pending.proposals.length,assumed:e.assumed,...e.force?{force:!0}:{}})+`
5
5
  `),0;let v=x(e);process.stdout.write(`${e.sid} ${e.verb??"extract"} \xB7 ${v} \xB7 ${e.mode} \xB7 expires in ${b(e.expires_at)}
@@ -12,7 +12,7 @@ import{b as $}from"./chunk-RX6776AI.js";import{a as w}from"./chunk-R7KXAISS.js";
12
12
  `);for(let[a,u]of i.entries())process.stdout.write(` q${a+1} [${u.risk}] ${u.text}
13
13
  `),u.options.forEach((d,_)=>{let y=_===u.recommended_index?" (recommended)":"";process.stdout.write(` - ${$(d.label)}${y}${d.detail?` \u2014 ${d.detail}`:""}
14
14
  `)});return e.assumed.length>0&&process.stdout.write(` assumed while away: ${e.assumed.map(a=>`${a.questionId}\u2192${a.optionId}`).join(", ")}
15
- `),0}async function I(t,n,o){{let{remoteEntry:s}=await import("./remote-entry-X6JMPC2K.js"),r=await s(t==="discard"?"context sessions discard":"context sessions",n.mode==="agent",void 0,{onboard:n.json!==!0});if(r!==null){if("exit"in r)return r.exit;let{remoteSessions:c}=await import("./sessions-remote-IWHWIQ2T.js");return c(t,n,o,r.choice)}}let e=g(process.cwd());if(t==="show")return o?j(e,o,!!n.json):(process.stderr.write(`error: sessions show needs a <sid> (kane-cli context sessions lists them)
15
+ `),0}async function I(t,n,o){{let{remoteEntry:s}=await import("./remote-entry-BCTFT643.js"),r=await s(t==="discard"?"context sessions discard":"context sessions",n.mode==="agent",void 0,{onboard:n.json!==!0});if(r!==null){if("exit"in r)return r.exit;let{remoteSessions:c}=await import("./sessions-remote-Y4FTZL7Y.js");return c(t,n,o,r.choice)}}let e=g(process.cwd());if(t==="show")return o?j(e,o,!!n.json):(process.stderr.write(`error: sessions show needs a <sid> (kane-cli context sessions lists them)
16
16
  `),2);if(t==="clean"){let{removed:s,skipped:r}=f(e,{all:n.all,sid:o});for(let c of r)process.stderr.write(`error: session ${c.sid} not removed \u2014 ${c.reason}
17
17
  `);return o&&s.length===0?(r.length>0||process.stderr.write(`error: no session ${o}
18
18
  `),2):(process.stdout.write(s.length?`removed: ${s.join(", ")}
@@ -1,3 +1,3 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{d as h}from"./chunk-734ORT6O.js";import"./chunk-XQMWHPZI.js";import{a as g,k as L,l as K,m as q,u as F,v as Y}from"./chunk-DDZLCAEO.js";import"./chunk-RHGW7B5Q.js";import{f as P,g as $,k as U}from"./chunk-HCJ2N3XB.js";import{a as C}from"./chunk-NLZZLANH.js";import{e as _}from"./chunk-3F5FMH76.js";import{d as R,e as w,i as b}from"./chunk-XMPTFXPW.js";import{c as T}from"./chunk-ZU4W2QGM.js";import"./chunk-73Y6T2UK.js";import"./chunk-P2ZQDQDB.js";import"./chunk-3BSYOCSW.js";import"./chunk-EECDDDSB.js";import"./chunk-7NPTL66J.js";import"./chunk-3QICDXY5.js";import"./chunk-4IEQNX7F.js";import"./chunk-MNBGG4H3.js";import"./chunk-REKHAN53.js";import"./chunk-GRURFGBP.js";import"./chunk-MYZHOBS4.js";import"./chunk-RF37IJNN.js";import"./chunk-XZYA7DNH.js";import{B as I,Ha as i,S as x,ba as A,f as O,ha as D,j as N,x as k}from"./chunk-7HMSMAUG.js";import"./chunk-GFLB2SHW.js";import"./chunk-2TVPA3LL.js";import"./chunk-VJGWVBZR.js";import"./chunk-22PIMG52.js";import{a as j}from"./chunk-I2MC6VVX.js";import"./chunk-RPRXRKKR.js";import"./chunk-QXQ7KVEN.js";import"./chunk-7AET4JKQ.js";import"./chunk-DJC7NTLA.js";import"./chunk-QSCXXNC2.js";import{oa as E}from"./chunk-UEE3RZN4.js";import"./chunk-DBMW3VUN.js";import"./chunk-KU3YHPWZ.js";import"./chunk-6NFOH4AC.js";import"./chunk-PUVMC4PX.js";import"./chunk-B7ZX5HEN.js";import"./chunk-VZ7KXRXB.js";import"./chunk-7V4BQSSV.js";import"./chunk-VO66KP2W.js";import"./chunk-HHW6MRU3.js";import"./chunk-7DFBOVUB.js";import"./chunk-4I7YN6YY.js";import"./chunk-6PIIUAZF.js";import"./chunk-NC7D7GOM.js";import"./chunk-ZCRZFAOT.js";import"./chunk-C2RUDJ46.js";import"./chunk-4QTH7VYE.js";import"./chunk-RZ4F3BHX.js";import"./chunk-A7RJQJNT.js";import"./chunk-HJMCXSUJ.js";import{a as S}from"./chunk-FOJHSG5M.js";import"./chunk-D36V5OX6.js";import"./chunk-UR6MHSHU.js";var z="any variables it declared stay in the folder it ran in";async function B(e){let o=e.mode==="agent",d=e.print??(t=>{process.stdout.write(`${t}
2
+ import{d as h}from"./chunk-5F44KH3R.js";import"./chunk-PEUIHME2.js";import{a as g,k as L,l as K,m as q,u as F,v as Y}from"./chunk-RDAIOJCR.js";import"./chunk-UICJ2KLJ.js";import{f as P,g as $,k as U}from"./chunk-LXCTV75T.js";import{a as C}from"./chunk-TAY7J5VS.js";import{c as T}from"./chunk-NVD2MXHQ.js";import"./chunk-73Y6T2UK.js";import{e as _}from"./chunk-VE4HLIGA.js";import{d as R,e as w,i as b}from"./chunk-XMPTFXPW.js";import"./chunk-GAKBHNC4.js";import"./chunk-U2VYTVKV.js";import"./chunk-2COXO5LQ.js";import"./chunk-3V4J65GN.js";import"./chunk-LZPYIFHZ.js";import"./chunk-32MFECUA.js";import"./chunk-4IEQNX7F.js";import"./chunk-23DKB2MT.js";import"./chunk-REKHAN53.js";import"./chunk-EHB55V23.js";import"./chunk-7V34ZMMS.js";import"./chunk-B7ZX5HEN.js";import"./chunk-W2HRX3DR.js";import"./chunk-PVN64537.js";import{B as I,Ha as i,S as x,ba as A,f as O,ha as D,j as N,x as k}from"./chunk-H4TIVILC.js";import"./chunk-GFLB2SHW.js";import"./chunk-2TVPA3LL.js";import"./chunk-VJGWVBZR.js";import"./chunk-22PIMG52.js";import"./chunk-RQKMSNEU.js";import{a as j}from"./chunk-4C7WVQOD.js";import"./chunk-QXQ7KVEN.js";import"./chunk-OKA6FPJM.js";import"./chunk-B57ZRHEQ.js";import"./chunk-QSCXXNC2.js";import"./chunk-6PIIUAZF.js";import{oa as E}from"./chunk-PI7OXS62.js";import"./chunk-DBMW3VUN.js";import"./chunk-KU3YHPWZ.js";import"./chunk-7V4BQSSV.js";import"./chunk-ZAQGIC33.js";import"./chunk-VO66KP2W.js";import"./chunk-G4K3TP2I.js";import"./chunk-YJAQZMJT.js";import"./chunk-HYJVYYAZ.js";import"./chunk-VZ7KXRXB.js";import"./chunk-UJLULWSR.js";import"./chunk-ZCRZFAOT.js";import"./chunk-FI2DVNRT.js";import"./chunk-4QTH7VYE.js";import"./chunk-RZ4F3BHX.js";import"./chunk-A7RJQJNT.js";import"./chunk-K75WIRI5.js";import{a as S}from"./chunk-FOJHSG5M.js";import"./chunk-FAMQ4DHU.js";import"./chunk-UR6MHSHU.js";var z="any variables it declared stay in the folder it ran in";async function B(e){let o=e.mode==="agent",d=e.print??(t=>{process.stdout.write(`${t}
3
3
  `)}),r=(...t)=>t.forEach(c=>d(c)),n=(t,c)=>(o?e.emit({type:"error",code:t.code,message:t.message,...I(t)}):(U(t),r("")),c),m=()=>(o?e.emit({type:"session_discard",phase:"discarded",sid:e.sid}):r(x,""),0),u=!1,f=()=>(o?e.emit({type:"session_discard",phase:"discarded",sid:e.sid}):r(`discarded \u2014 nothing was saved${u?`; ${z}`:""}`,""),0),p=t=>t?.scope?.state==="finalized"?n(i.alreadySaved(),2):t?.scope?.state==="discarded"?m():n(i.savedOrDiscarded(),2);try{let t;try{t=await e.person.getSession(e.sid)}catch(s){if(s instanceof j&&(s.code==="NOT_FOUND"||s.code==="NOT_SESSION_OWNER"))return n(i.noSuchSession(e.sid),2);throw s}if(u=t.verb==="design",t.scope?.state&&t.scope.state!=="open")return p(t);if(t.status==="running"&&t.ended===null)return n(i.goingOnElsewhere(e.sid),2);let c=await A(e.person,e.projectId,e.sid);if(o){let s=g({kind:"save",sid:e.sid,phase:"check",project:e.projectName,counts:c});if(s){let{type:a,...y}=s;e.emit({type:"session_discard",...y})}if(!e.yes)return n(i.confirmDiscardRequired(e.sid),2)}else{let s=L({...q(c),adds:D(c)}),a=(t.useCase?t.useCaseTitle:t.sourceTitle)??null,y=a?`"${a}"`:t.useCase?E(t.useCase):t.sourceId,G=[t.verb,...y?[y]:[],F(t.lastActivityAt??t.createdAt,Date.now())].filter(Boolean).join(" \xB7 ");r(S.bold("discard this session"));let W=[["session",G],["holds",`${s}, not saved yet`],...u?[["stays","any variables it declared, in the folder it ran in"]]:[],["then",K(s,e.projectName)]];for(let[v,l]of W)r(`${S.dim(` ${v.padEnd(10)}`)}${l}`);if(r(""),!e.yes){let v=await e.confirm("discard this session? (y/N)");if(r(""),!v)return 0;let l=await e.person.getSession(e.sid);if(l.scope?.state&&l.scope.state!=="open")return p(l);if(l.status==="running"&&l.ended===null)return n(i.goingOnElsewhere(e.sid),2)}}try{await e.person.discard(e.sid)}catch(s){if(!(s instanceof j))throw s;if(s.code==="SCOPE_NOT_OPEN")return p(await e.person.getSession(e.sid).catch(()=>null));if(s.code==="NOT_FOUND"||s.code==="NOT_SESSION_OWNER")return n(i.noSuchSession(e.sid),2);if(s.code==="SESSION_HELD")return n(i.goingOnElsewhere(e.sid),2);if(s.retryable){let a=await e.person.getSession(e.sid).catch(()=>null);if(a===null)return n(i.discardUnconfirmed(),2);if(a.scope?.state==="discarded")return f()}throw s}return f()}catch{return n(i.discardFailed(),1)}}async function ge(e,o,d,r){let n=o.mode==="agent",m=s=>P(s,e==="discard"?"sessions discard":"sessions",n);if(e==="show"||e==="clean")return m(i.sessionsLocalOnly(e));if(e!==void 0&&e!=="save"&&e!=="discard")return m({code:"USAGE",message:`unknown sessions action '${e}'`,remedy:"run kane-cli context sessions, kane-cli context sessions save <sid>, or kane-cli context sessions discard <sid>"});if((e==="save"||e==="discard")&&!d)return m({code:"USAGE",message:`sessions ${e} needs a <sid>`,remedy:"kane-cli context sessions --json lists them"});if((e==="save"||e==="discard")&&!n&&!R()&&o.yes!==!0)return m(e==="save"?i.confirmRequired():i.confirmDiscardRequired());let u;try{u=await _()}catch(s){if(s instanceof b)return m({code:s.code,message:s.message,...s.remedy?{remedy:s.remedy}:{}});throw s}let f=O({url:r.latticeUrl,basicAuth:u});if(e===void 0)try{return await Y({person:f,projectId:r.projectId,me:T(process.cwd()),json:o.json===!0||n,out:s=>{process.stdout.write(s)},log:C("remote-sessions")})}catch(s){return k(s,$(i.assuranceOffOr(s,r.projectName,i.listFailed()),"sessions",n))}if(e==="discard"){let s=n?w("ndjson","discard"):null,a=await B({person:f,projectId:r.projectId,projectName:r.projectName,sid:d,mode:n?"agent":"interactive",yes:o.yes===!0,confirm:H,emit:y=>s?.event(y)});return s?s.done(a):a}let p=()=>N({url:r.latticeUrl,sessionId:d,basicAuth:u}).eventsAfter(0);if(!n)return h({person:f,projectId:r.projectId,projectName:r.projectName,sid:d,mode:"interactive",yes:o.yes===!0,confirm:H,onProgress:()=>{},emit:()=>{},sessionLog:p});let t=w("ndjson","save"),c=await h({person:f,projectId:r.projectId,projectName:r.projectName,sid:d,mode:"agent",yes:o.yes===!0,confirm:async()=>!1,onProgress:s=>{let a=g(s);a&&t.event(a)},emit:s=>t.event(s),sessionLog:p});return t.done(c)}async function H(e){let{createInterface:o}=await import("readline/promises"),d=o({input:process.stdin,output:process.stdout});try{return/^y(es)?$/i.test((await d.question(`${e} `)).trim())}finally{d.close()}}export{ge as remoteSessions};
@@ -1,3 +1,3 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as g,b as y}from"./chunk-P3JXJ4BW.js";import{b as m}from"./chunk-7AET4JKQ.js";import"./chunk-C2RUDJ46.js";import{a as f}from"./chunk-RZ4F3BHX.js";import"./chunk-HJMCXSUJ.js";import{a as p,g as u,h as d}from"./chunk-D36V5OX6.js";import"./chunk-UR6MHSHU.js";import{mkdirSync as S,writeFileSync as w,readFileSync as T,rmSync as c,cpSync as b,copyFileSync as h,createWriteStream as A,existsSync as I}from"fs";import{join as a}from"path";import{tmpdir as v}from"os";import{spawn as $}from"child_process";import{Readable as E}from"stream";import{pipeline as L}from"stream/promises";function R(t){try{return T(a(t,"VERSION"),"utf-8").trim()||null}catch{return null}}function x(t,r,i){return i?t!==r:t===null||m(t,r)>0}function C(t){return/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/.test(t)}function _(t){let r=u.split("/").pop()??u;return`https://registry.npmjs.org/${u}/-/${r}-${t}.tgz`}var N=5e3,M=6e4;async function z(){let t=new AbortController,r=setTimeout(()=>t.abort(),N);try{let i=await f(g(),{headers:{Accept:"application/json"},signal:t.signal});if(!i.ok)throw new Error(`Controller returned ${i.status} fetching skill version map`);let l=await i.json(),n=y(l,p);if(!n)throw new Error("No compatible skill version found for this kane-cli build");return n}finally{clearTimeout(r)}}async function P(t){let r=_(t),i=new AbortController,l=setTimeout(()=>i.abort(),M);try{let n=await f(r,{headers:{Accept:"application/octet-stream"},signal:i.signal});if(!n.ok||!n.body)throw new Error(`Failed to download skill tarball (${n.status})`);let e=a(v(),`kane-cli-skill-${t}-${process.pid}.tgz`);return await L(E.fromWeb(n.body),A(e)),e}finally{clearTimeout(l)}}var k=".skill-tarball.tgz";function O(t,r){S(r,{recursive:!0});let i=a(r,k);return h(t,i),new Promise((l,n)=>{let e=$("tar",["-xzf",k,"--strip-components=2","package/skills"],{cwd:r,stdio:["ignore","ignore","pipe"]}),o="";e.stderr?.on("data",s=>{o+=s.toString()}),e.on("error",s=>n(s)),e.on("close",s=>{s===0?l():n(new Error(`tar exited ${s}${o?`: ${o.trim()}`:""}`))})}).finally(()=>{try{c(i,{force:!0})}catch{}})}async function H(t){if(t!==void 0&&!C(t))return{status:"failed",version:t,installedTargets:0,error:`Invalid skill version ${JSON.stringify(t)} - expected a semver such as 0.0.19`};let r;try{r=t??await z()}catch(e){return{status:"failed",version:t??"unknown",installedTargets:0,error:e instanceof Error?e.message:String(e)}}let i=d.filter(({dir:e})=>x(R(e),r,!!t));if(i.length===0)return{status:"already-installed",version:r,installedTargets:0};let l=null,n=null;try{if(n=await P(r),l=a(v(),`kane-cli-skill-${r}-stage-${process.pid}`),c(l,{recursive:!0,force:!0}),await O(n,l),!I(a(l,"SKILL.md")))throw new Error(`Unexpected skill tarball layout for v${r}: SKILL.md not at package/skills/ root`);let e=0;for(let{dir:o}of i)try{c(o,{recursive:!0,force:!0}),S(o,{recursive:!0}),b(l,o,{recursive:!0,force:!0}),w(a(o,"VERSION"),r+`
2
+ import{a as g,b as y}from"./chunk-7DLDADQR.js";import{b as m}from"./chunk-OKA6FPJM.js";import"./chunk-FI2DVNRT.js";import{a as f}from"./chunk-RZ4F3BHX.js";import"./chunk-K75WIRI5.js";import{a as p,g as u,h as d}from"./chunk-FAMQ4DHU.js";import"./chunk-UR6MHSHU.js";import{mkdirSync as S,writeFileSync as w,readFileSync as T,rmSync as c,cpSync as b,copyFileSync as h,createWriteStream as A,existsSync as I}from"fs";import{join as a}from"path";import{tmpdir as v}from"os";import{spawn as $}from"child_process";import{Readable as E}from"stream";import{pipeline as L}from"stream/promises";function R(t){try{return T(a(t,"VERSION"),"utf-8").trim()||null}catch{return null}}function x(t,r,i){return i?t!==r:t===null||m(t,r)>0}function C(t){return/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/.test(t)}function _(t){let r=u.split("/").pop()??u;return`https://registry.npmjs.org/${u}/-/${r}-${t}.tgz`}var N=5e3,M=6e4;async function z(){let t=new AbortController,r=setTimeout(()=>t.abort(),N);try{let i=await f(g(),{headers:{Accept:"application/json"},signal:t.signal});if(!i.ok)throw new Error(`Controller returned ${i.status} fetching skill version map`);let l=await i.json(),n=y(l,p);if(!n)throw new Error("No compatible skill version found for this kane-cli build");return n}finally{clearTimeout(r)}}async function P(t){let r=_(t),i=new AbortController,l=setTimeout(()=>i.abort(),M);try{let n=await f(r,{headers:{Accept:"application/octet-stream"},signal:i.signal});if(!n.ok||!n.body)throw new Error(`Failed to download skill tarball (${n.status})`);let e=a(v(),`kane-cli-skill-${t}-${process.pid}.tgz`);return await L(E.fromWeb(n.body),A(e)),e}finally{clearTimeout(l)}}var k=".skill-tarball.tgz";function O(t,r){S(r,{recursive:!0});let i=a(r,k);return h(t,i),new Promise((l,n)=>{let e=$("tar",["-xzf",k,"--strip-components=2","package/skills"],{cwd:r,stdio:["ignore","ignore","pipe"]}),o="";e.stderr?.on("data",s=>{o+=s.toString()}),e.on("error",s=>n(s)),e.on("close",s=>{s===0?l():n(new Error(`tar exited ${s}${o?`: ${o.trim()}`:""}`))})}).finally(()=>{try{c(i,{force:!0})}catch{}})}async function H(t){if(t!==void 0&&!C(t))return{status:"failed",version:t,installedTargets:0,error:`Invalid skill version ${JSON.stringify(t)} - expected a semver such as 0.0.19`};let r;try{r=t??await z()}catch(e){return{status:"failed",version:t??"unknown",installedTargets:0,error:e instanceof Error?e.message:String(e)}}let i=d.filter(({dir:e})=>x(R(e),r,!!t));if(i.length===0)return{status:"already-installed",version:r,installedTargets:0};let l=null,n=null;try{if(n=await P(r),l=a(v(),`kane-cli-skill-${r}-stage-${process.pid}`),c(l,{recursive:!0,force:!0}),await O(n,l),!I(a(l,"SKILL.md")))throw new Error(`Unexpected skill tarball layout for v${r}: SKILL.md not at package/skills/ root`);let e=0;for(let{dir:o}of i)try{c(o,{recursive:!0,force:!0}),S(o,{recursive:!0}),b(l,o,{recursive:!0,force:!0}),w(a(o,"VERSION"),r+`
3
3
  `),e++}catch{}return e===0?{status:"failed",version:r,installedTargets:0,error:"Could not write to any agent skill directory"}:{status:"installed",version:r,installedTargets:e}}catch(e){return{status:"failed",version:r,installedTargets:0,error:e instanceof Error?e.message:String(e)}}finally{if(n)try{c(n,{force:!0})}catch{}if(l)try{c(l,{recursive:!0,force:!0})}catch{}}}function Q(t){switch(t.status){case"installed":return`Installed kane-cli skill v${t.version} (${t.installedTargets}/${d.length} agent dirs). Restart your AI agent (Claude Code / Codex CLI / Gemini CLI) to load it.`;case"already-installed":return`kane-cli skill v${t.version} already installed.`;case"failed":return`Failed to install kane-cli skill: ${t.error??"unknown error"}`}}export{O as extractSkills,Q as formatInstallResult,H as installSkill,C as isValidSkillVersion,x as targetNeedsInstall};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a,b,c,d,e,f}from"./chunk-CB344EDO.js";import"./chunk-FNUGDPTS.js";import"./chunk-TD6GCEIK.js";import"./chunk-4C7WVQOD.js";import"./chunk-HYJVYYAZ.js";import"./chunk-UR6MHSHU.js";export{d as CHECKPOINT_SAVE_DEADLINE_MS,b as assurancePackageName,e as buildAgentEnv,c as findAssuranceAgent,a as platformPackageName,f as resolveAgentAuthEnv};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a,b}from"./chunk-CGITGJ3I.js";import"./chunk-5D7ENQTQ.js";import"./chunk-2XW33VOK.js";import"./chunk-7HO4NX5W.js";import"./chunk-A7RJQJNT.js";import"./chunk-D36V5OX6.js";import"./chunk-UR6MHSHU.js";export{a as DEFAULT_TUI_CONFIG,b as TuiConfigStore};
2
+ import{a,b}from"./chunk-BHQIH2FE.js";import"./chunk-5D7ENQTQ.js";import"./chunk-2XW33VOK.js";import"./chunk-7HO4NX5W.js";import"./chunk-A7RJQJNT.js";import"./chunk-FAMQ4DHU.js";import"./chunk-UR6MHSHU.js";export{a as DEFAULT_TUI_CONFIG,b as TuiConfigStore};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a,b,c,d,e,f,g,h}from"./chunk-NVD2MXHQ.js";import"./chunk-73Y6T2UK.js";import"./chunk-H4TIVILC.js";import"./chunk-GFLB2SHW.js";import"./chunk-2TVPA3LL.js";import"./chunk-VJGWVBZR.js";import"./chunk-22PIMG52.js";import"./chunk-RQKMSNEU.js";import"./chunk-4C7WVQOD.js";import"./chunk-QXQ7KVEN.js";import"./chunk-OKA6FPJM.js";import"./chunk-B57ZRHEQ.js";import"./chunk-QSCXXNC2.js";import"./chunk-6PIIUAZF.js";import"./chunk-PI7OXS62.js";import"./chunk-DBMW3VUN.js";import"./chunk-KU3YHPWZ.js";import"./chunk-7V4BQSSV.js";import"./chunk-ZAQGIC33.js";import"./chunk-VO66KP2W.js";import"./chunk-G4K3TP2I.js";import"./chunk-YJAQZMJT.js";import"./chunk-HYJVYYAZ.js";import"./chunk-UJLULWSR.js";import"./chunk-ZCRZFAOT.js";import"./chunk-FI2DVNRT.js";import"./chunk-RZ4F3BHX.js";import"./chunk-K75WIRI5.js";import"./chunk-FAMQ4DHU.js";import"./chunk-UR6MHSHU.js";export{a as PROJECT_FILE,b as chooseStore,f as linkFolderIsAFile,c as projectUser,e as readProjectFile,d as rememberUser,h as removeProjectFile,g as writeProjectFile};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{N as a,O as b,P as c,Q as d,R as e,S as f,T as g,U as h,V as i,W as j}from"./chunk-45NM23EQ.js";import"./chunk-6JUS2ULI.js";import"./chunk-HG2ILWCE.js";import"./chunk-BSRSXYDZ.js";import"./chunk-CB4ARIHR.js";import"./chunk-UWPG5MWM.js";import"./chunk-73Y6T2UK.js";import"./chunk-XMPTFXPW.js";import"./chunk-SMXABALN.js";import"./chunk-WN5VKKJ3.js";import"./chunk-23DKB2MT.js";import"./chunk-VRIZDOO5.js";import"./chunk-ZHWU6L2G.js";import"./chunk-CQDCNP7V.js";import"./chunk-7V34ZMMS.js";import"./chunk-B7ZX5HEN.js";import"./chunk-6PIIUAZF.js";import"./chunk-PI7OXS62.js";import"./chunk-DBMW3VUN.js";import"./chunk-KU3YHPWZ.js";import"./chunk-7V4BQSSV.js";import"./chunk-ZAQGIC33.js";import"./chunk-G4K3TP2I.js";import"./chunk-YJAQZMJT.js";import"./chunk-HYJVYYAZ.js";import"./chunk-VZ7KXRXB.js";import"./chunk-UJLULWSR.js";import"./chunk-ZCRZFAOT.js";import"./chunk-RZ4F3BHX.js";import"./chunk-A7RJQJNT.js";import"./chunk-HCBYKLMW.js";import"./chunk-33DWJV67.js";import"./chunk-FOJHSG5M.js";import"./chunk-6YGTRKDT.js";import"./chunk-FAMQ4DHU.js";import"./chunk-UR6MHSHU.js";export{f as behindWarning,a as cmdErr,c as confirmDestructive,i as fenceEvent,h as rebaseFence,j as refuseIfRebaseOpen,b as requireStore,d as stdCmdIO,g as syncBehindEvent,e as warnIfBehind};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a,b}from"./chunk-MYVKUJGS.js";import"./chunk-UEE3RZN4.js";import"./chunk-DBMW3VUN.js";import"./chunk-KU3YHPWZ.js";import"./chunk-6NFOH4AC.js";import"./chunk-7V4BQSSV.js";import"./chunk-7DFBOVUB.js";import"./chunk-4I7YN6YY.js";import"./chunk-UR6MHSHU.js";export{a as localSite,b as remoteSite};
2
+ import{a,b}from"./chunk-35BG2EMW.js";import"./chunk-PI7OXS62.js";import"./chunk-DBMW3VUN.js";import"./chunk-KU3YHPWZ.js";import"./chunk-7V4BQSSV.js";import"./chunk-ZAQGIC33.js";import"./chunk-YJAQZMJT.js";import"./chunk-HYJVYYAZ.js";import"./chunk-UR6MHSHU.js";export{a as localSite,b as remoteSite};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a,b,c,d,e}from"./chunk-W54BX6HC.js";import"./chunk-VJGWVBZR.js";import"./chunk-PI7OXS62.js";import"./chunk-DBMW3VUN.js";import"./chunk-KU3YHPWZ.js";import"./chunk-7V4BQSSV.js";import"./chunk-ZAQGIC33.js";import"./chunk-YJAQZMJT.js";import"./chunk-HYJVYYAZ.js";import"./chunk-UR6MHSHU.js";export{c as awaitingField,d as awaitingNote,e as awaitingOfUseCase,b as streamOfCommit,a as streamWarnings};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u}from"./chunk-MSYRAPDK.js";import"./chunk-SALZ6WSF.js";import"./chunk-ENRFXGID.js";import"./chunk-X6FCXBXU.js";import"./chunk-45NM23EQ.js";import"./chunk-6JUS2ULI.js";import"./chunk-HG2ILWCE.js";import"./chunk-BSRSXYDZ.js";import"./chunk-CB4ARIHR.js";import"./chunk-SSOUYKVG.js";import"./chunk-HVOXMCKE.js";import"./chunk-WMGKUERB.js";import"./chunk-UWPG5MWM.js";import"./chunk-73Y6T2UK.js";import"./chunk-XMPTFXPW.js";import"./chunk-SMXABALN.js";import"./chunk-WN5VKKJ3.js";import"./chunk-MINDIQET.js";import"./chunk-LX2I4JEH.js";import"./chunk-GEZVC4S3.js";import"./chunk-IZ66FKPC.js";import"./chunk-E4GIGM5V.js";import"./chunk-3KY7HHQU.js";import"./chunk-LD5B3QFW.js";import"./chunk-ZHAMVLQZ.js";import"./chunk-Z24SD2EJ.js";import"./chunk-AQ2OG2EF.js";import"./chunk-4IEQNX7F.js";import"./chunk-23DKB2MT.js";import"./chunk-VRIZDOO5.js";import"./chunk-ZHWU6L2G.js";import"./chunk-GJXO6FF7.js";import"./chunk-LLQWEGXD.js";import"./chunk-ZCIWQHCO.js";import"./chunk-CQDCNP7V.js";import"./chunk-7V34ZMMS.js";import"./chunk-B7ZX5HEN.js";import"./chunk-VJGWVBZR.js";import"./chunk-6PIIUAZF.js";import"./chunk-PI7OXS62.js";import"./chunk-DBMW3VUN.js";import"./chunk-KU3YHPWZ.js";import"./chunk-7V4BQSSV.js";import"./chunk-ZAQGIC33.js";import"./chunk-G4K3TP2I.js";import"./chunk-YJAQZMJT.js";import"./chunk-HYJVYYAZ.js";import"./chunk-VZ7KXRXB.js";import"./chunk-UJLULWSR.js";import"./chunk-ZCRZFAOT.js";import"./chunk-RZ4F3BHX.js";import"./chunk-A7RJQJNT.js";import"./chunk-HCBYKLMW.js";import"./chunk-33DWJV67.js";import"./chunk-FOJHSG5M.js";import"./chunk-6YGTRKDT.js";import"./chunk-FAMQ4DHU.js";import"./chunk-UR6MHSHU.js";export{u as cloneCommand,f as credentialsFromFlags,p as existingCredentialFile,d as finishInterruptedReset,a as headless,t as pullCommand,s as pushCommand,b as refuse,q as restoreCredentialFile,e as resumeOpenRebase,o as runClone,k as runPull,l as runPush,m as runSync,g as runSyncAdd,n as runSyncDoctor,h as runSyncList,i as runSyncRemove,j as runSyncStatus,c as start,r as syncCommand};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as R,b as Y,g as _,o as N}from"./chunk-GXKY5A46.js";import"./chunk-Q3C6NDGI.js";import"./chunk-UYDHOHSZ.js";import{a as T,b as O,c as U,d as j}from"./chunk-72RC7JSA.js";import{L as E,M as H,Q as L,c as P,e as I}from"./chunk-MEKPGQAM.js";import"./chunk-DZOYYWOW.js";import"./chunk-VXGN3IV7.js";import"./chunk-CB4ARIHR.js";import"./chunk-BSRSXYDZ.js";import"./chunk-FIP5L6LV.js";import"./chunk-R7KXAISS.js";import"./chunk-WMGKUERB.js";import"./chunk-WOSANGV6.js";import{d as G,i as A}from"./chunk-XMPTFXPW.js";import{a as f}from"./chunk-73Y6T2UK.js";import"./chunk-SMXABALN.js";import"./chunk-WN5VKKJ3.js";import"./chunk-OJ33Q6DU.js";import"./chunk-D756UWY2.js";import"./chunk-LX2I4JEH.js";import"./chunk-O3HHTKZ5.js";import"./chunk-54XA5MZH.js";import"./chunk-3GXN6VF6.js";import"./chunk-LD5B3QFW.js";import"./chunk-42PALMW2.js";import"./chunk-AZLNLHUA.js";import"./chunk-AQ2OG2EF.js";import"./chunk-4IEQNX7F.js";import"./chunk-MNBGG4H3.js";import"./chunk-VRIZDOO5.js";import"./chunk-ZHWU6L2G.js";import"./chunk-EZN7CF45.js";import"./chunk-7XBNMOH4.js";import"./chunk-ZCIWQHCO.js";import"./chunk-ZFM77AQU.js";import"./chunk-VJGWVBZR.js";import"./chunk-UEE3RZN4.js";import"./chunk-DBMW3VUN.js";import"./chunk-KU3YHPWZ.js";import"./chunk-6NFOH4AC.js";import"./chunk-PUVMC4PX.js";import"./chunk-B7ZX5HEN.js";import"./chunk-VZ7KXRXB.js";import"./chunk-7V4BQSSV.js";import"./chunk-HHW6MRU3.js";import"./chunk-7DFBOVUB.js";import"./chunk-4I7YN6YY.js";import"./chunk-6PIIUAZF.js";import"./chunk-NC7D7GOM.js";import"./chunk-ZCRZFAOT.js";import"./chunk-RZ4F3BHX.js";import"./chunk-A7RJQJNT.js";import"./chunk-HCBYKLMW.js";import"./chunk-33DWJV67.js";import"./chunk-FOJHSG5M.js";import"./chunk-6YGTRKDT.js";import"./chunk-D36V5OX6.js";import"./chunk-UR6MHSHU.js";import{existsSync as y}from"fs";import{resolve as $}from"path";import{spawn as D}from"child_process";var w=class extends Error{},m=e=>{if(e===null)throw new w;return e},u=(e,t,o)=>({value:e,label:t,detail:o});async function p(e,t,o,n=!1){for(;;){let h=m(await e.input(t,o,n)).trim();if(h)return h;e.out("Enter a value, or press Esc to leave setup.")}}async function x(e,t){e.out(`Open in your browser: ${t}`);try{await e.open(t)}catch{e.out("The browser could not open automatically. Open that address yourself, then continue here.")}}async function b(e,t){let o=await e.gitRead(t);return o.ok||e.out(j(o.diagnostic,t)),o.ok}var S=u("change","Use a different address"),C=u("storage","Choose a different storage");async function z(e,t){for(;;)try{await e.checkGit();break}catch(n){e.out(n instanceof Error?n.message:"Git 2.31 or newer is required."),m(await e.choose("Install Git, then return here",[u("open","Open Git installation instructions"),u("retry","Check again")]))==="open"&&await x(e,"https://git-scm.com/downloads")}if(await b(e,t.gitUrl))return"ok";if(!/^https:\/\/github\.com\//i.test(t.gitUrl))for(e.out("Set up Git access for this repository with your server's SSH key or credential helper. kane-cli uses the same access as Git.");;){let n=m(await e.choose("Git cannot read this repository yet.",[u("retry","Check again"),S,C]));if(n==="change"||n==="storage")return n;if(await b(e,t.gitUrl))return"ok"}for(e.out("Sign in below if you have not, or ask the owner to grant your GitHub account access.");;){let n=m(await e.choose("Sign in to access this GitHub repository",[u("login","Sign in with your browser","Use or create your GitHub account."),u("retry","I've fixed my access \u2014 check again","Ask the owner to grant your account access, or check your existing Git login."),S,C]));if(n==="change"||n==="storage")return n;if(n==="login"){if((await e.gh(["--version"])).code){e.out("Browser sign-in uses GitHub CLI, a small GitHub tool. Install it once, then return to this step. GitHub CLI is optional if you already use SSH or another Git credential helper."),m(await e.choose("GitHub CLI is not installed",[u("open","Open installation instructions"),u("retry","Check again")]))==="open"&&await x(e,"https://cli.github.com/");continue}if((await e.gh(["auth","login","--hostname","github.com","--git-protocol","https","--web"],!0)).code){e.out("Sign-in did not finish. Your repository address is still saved in this setup.");continue}for(;(await e.gh(["auth","setup-git","--hostname","github.com"])).code&&(e.out("GitHub sign-in finished, but Git could not be told to use it."),m(await e.choose("Configure Git to use your GitHub sign-in",[u("retry","Try the configuration again"),u("skip","Skip; I use SSH or another credential helper")]))!=="skip"););}if(await b(e,t.gitUrl))return"ok";e.out("A browser login alone does not grant repository permission: ask the owner to grant your GitHub account access.")}}async function k(e){if(m(await e.choose("Access to the bucket",[u("existing","Use credentials already configured on this computer","Existing kane-cli credentials or KANE_SYNC_S3_ACCESS_KEY_ID and KANE_SYNC_S3_SECRET_ACCESS_KEY."),u("keys","Enter the access keys from my storage administrator","Saved in your local kane-cli configuration, never in the shared context.")]))!=="existing")return e.out("These are bucket access keys, not your cloud account password. Your administrator must grant access to the bucket and folder you selected."),{accessKeyId:await p(e,"Access key ID"),secretAccessKey:await p(e,"Secret access key (hidden)",void 0,!0)}}async function W(e,t){let o=t?.kind??m(await e.choose("Where should your team's shared context live?",[u("github","GitHub \u2014 Recommended","Guided setup for a repository: a storage space on GitHub."),u("s3","S3-compatible storage","Use your team's existing cloud bucket and access keys."),u("folder","Folder","A local folder stays on this computer. A mounted shared drive can serve your team.")]));if(o==="github"){t||(e.out("GitHub will hold the requirements, documents and test information you publish from kane-cli. Each teammate signs in with their own account."),m(await e.choose("Choose a GitHub repository",[u("existing","Use an existing repository"),u("create","Create a repository on GitHub","Use a dedicated repository. Choose Private to limit who can see your context.")]))==="create"&&(await x(e,"https://github.com/new"),e.out("On GitHub: choose the owner and repository name, choose Private, and create the repository. Return here and paste its HTTPS address. No code or Git knowledge is needed.")));let d=await p(e,"Repository address (for example https://github.com/my-team/team-context.git)",t?.address);return{location:d,journey:{kind:o,address:d}}}if(o==="folder"){t||e.out("Everyone needs access to the same mounted drive to share through a folder. Sending a local path does not share its contents. Dropbox, iCloud, OneDrive and Google Drive sync folders are not supported.");let d=await p(e,"Folder path",t?.address);return{location:d,journey:{kind:o,address:d}}}t||e.out("Ask your storage administrator for an existing bucket and access keys. kane-cli does not create buckets or cloud permissions.");let n=t?.s3,h=await p(e,"Bucket name",n?.bucket);for(;!/^[a-zA-Z0-9.-]+$/.test(h);)e.out("Use the bucket's name, not a URL."),h=await p(e,"Bucket name");let c=await p(e,"Region",n?.region??"us-east-1"),s=m(await e.input("Folder inside the bucket (optional)",n?.prefix??"")),i=[u("aws","Amazon S3"),u("compatible","Another S3-compatible service")];n&&i.sort((d,g)=>+(g.value===n.service)-+(d.value===n.service));let l=m(await e.choose("Which storage service?",i)),r=new URLSearchParams({region:c}),a=l==="compatible"?await p(e,"Service endpoint (https://host, with an optional port)",n?.service===l?n.endpoint:void 0):void 0;return a&&r.set("endpoint",a),{location:`s3://${h}/${s.split("/").map(encodeURIComponent).join("/")}?${r}`,journey:{kind:"s3",s3:{bucket:h,region:c,prefix:s,service:l,endpoint:a}}}}function K(e){return e.kind==="dir"?"A location address contains no password: everyone who can open this folder can read it; sending the path does not send its contents.":e.kind==="s3"?"A location address contains no keys and does not grant access: grant teammates access to the bucket in your storage's console.":U(e.gitUrl??"")==="github.com"?"A location address contains no password and does not grant access. Invite teammates on GitHub.":"A location address contains no password and does not grant access: grant teammates access on your Git server."}async function J(e,t){try{e.out("Share your context: the requirements, documents and test information you add to kane-cli. A location is where your team's shared copy lives.");let o=m(await e.choose("What do you want to do?",[u("share","Share my context with my team"),u("join","Join my team's context")]));if(o==="share"&&!y(f(t)))return e.out("There is no context here to share yet. Add your documents with kane-cli context ingest <files>, then run kane-cli context sync setup again."),2;let n,h=async()=>{for(;;){let r;for(;;){let a;if(o==="join")a=await p(e,"Paste the location your teammate shared",n?.address),n={kind:"join",address:a};else{let d=await W(e,n);a=d.location,n=d.journey}try{r=E(a,t);break}catch(d){e.out(d instanceof Error?d.message:"That location could not be read.")}}if(r.kind==="fake")throw new Error("This location is only available to tests.");if(r.kind==="git"){let a=await z(e,r);if(a==="storage"&&(n=void 0),a!=="ok")continue;if(/^https:\/\/github\.com\//i.test(r.gitUrl)){let d=await e.gh(["repo","view",r.gitUrl,"--json","nameWithOwner,visibility"]),g;try{let v=JSON.parse(d.text);["PUBLIC","PRIVATE","INTERNAL"].includes(v.visibility)&&(g=v.visibility)}catch{}e.out(g?`Repository visibility: ${g.toLowerCase()}.`:"Repository visibility could not be checked automatically. Check Public/Private on GitHub before publishing.")}}return r}},c=await h(),s=c.kind==="s3"?await k(e):void 0,i="origin",l;if(o==="join")for(;l=$(t,await p(e,"Download into a new folder","team-context")),!!y(l);)e.out("That folder already exists. Choose a new folder so your current context and files stay untouched.");else{let r=P(f(t)).locations;for(;r.some(a=>a.name===i)||!/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(i);)i=await p(e,"Choose a new name for this connection","team")}for(e.out(`Location: ${c.gitUrl??c.path??c.location}`),e.out(c.kind==="git"?"Connection checks add small permanent files, commits and a scratch reference to this repository. Your own context is uploaded only by a separate publish command.":"Connection checks add small permanent files to this location. Your own context is uploaded only by a separate publish command."),m(await e.choose(o==="join"?"Connect and download team context?":"Connect this location? Your context will not be uploaded.",[u("connect",o==="join"?"Connect and download":"Connect location")]));e.out(o==="join"?"Checking access and downloading verified team context\u2026":"Checking read access and safe publishing\u2026"),(o==="join"?await e.clone(c.location,l,s):await e.add(i,c.location,s))!==0;){if(o==="join"&&y(l)){e.out(`The destination ${l} now exists after the interrupted attempt. Keep it; choose a new folder for a fresh download.`);do l=$(t,await p(e,"New download folder"));while(y(l))}let a=[u("retry","Retry this connection"),...c.kind==="s3"?[u("keys","Enter different keys")]:[],S,...o==="share"?[C]:[]],d=m(await e.choose("The connection did not finish. Your choices are kept; fix the reported issue and retry.",a));d==="keys"&&(s=await k(e)),(d==="change"||d==="storage")&&(d==="storage"&&(n=void 0),c=await h(),s=c.kind==="s3"?await k(e):void 0)}if(o==="join")e.out(`Team context downloaded into ${l}. Your previous local files were not replaced.`),e.out("Next: open that folder and run kane-cli context sync status.");else{let r=e.access(i);e.out(`Connected to ${c.gitUrl??c.path??c.location}. ${r==="write"?"You can download and publish changes.":"You can download context, but cannot publish changes."}`),e.out("Your context has not been uploaded yet."),e.out(r==="write"?`When ready, publish with kane-cli context push ${i}. This shares your context records and their referenced source documents with everyone who can read the location.`:"Ask the location owner for write access before publishing, then check the connection again."),e.out(`Share this location with teammates: ${H(c)}`),e.out(K(c))}return 0}catch(o){return o instanceof w?(e.out("Setup left. Your context has not been published. Any completed connection checks remain in the location."),3):(e.out(o instanceof Error?o.message:"Setup could not finish."),2)}}async function q(e,t=!1){return new Promise(o=>{let n=D("gh",e,{stdio:t?"inherit":["ignore","pipe","pipe"],windowsHide:!0}),h="";n.stdout?.on("data",s=>{h.length<64e3&&(h+=String(s))}),n.stderr?.on("data",()=>{});let c=setTimeout(()=>n.kill("SIGKILL"),t?3e5:2e4);n.on("error",()=>{clearTimeout(c),o({code:1,text:"GitHub CLI is unavailable"})}),n.on("close",s=>{clearTimeout(c),o({code:s??1,text:h})})})}async function ie(e,t=L(),o=process.cwd()){if(e.mode&&e.mode!=="interactive"||!G())return Y(R(e,t),t,new A("TTY_REQUIRED","guided setup needs an interactive terminal; for automation use kane-cli context sync add <name> <location> or kane-cli context clone <location> <new-folder>","run kane-cli context sync setup in a terminal"),2);let{promptSetup:n}=await import("./sync-setup-ui-XITPGSO4.js"),h=(s,i)=>i(s?{credentials:s}:{}),c=async s=>{let i=[],l=await s({...t,out:r=>i.push(r),err:r=>i.push(r)});if(l!==0)for(let r of i){if(r.startsWith("next: ")||r.startsWith("checking "))continue;let a=r.startsWith("error: ")?r.slice(7):r,d=/^([a-z][a-z0-9+.-]*:\/\/|[a-z0-9._-]+@[a-z0-9.-]+[:/]|[\/~.])/i.test(a);t.out(/^[a-z]/.test(a)&&!d?a.charAt(0).toUpperCase()+a.slice(1)+(/[.!?]$/.test(a)?"":"."):a)}return l};return J({out:t.out,choose:(s,i)=>n({title:s,choices:i}),input:(s,i,l)=>n({title:s,initial:i,secret:l}),open:async s=>{let{default:i}=await import("./open-MQLQKFAW.js");await i(s)},checkGit:()=>O(),gitRead:async s=>{try{let i=await T(["ls-remote",s],{timeout:2e4});return{ok:i.code===0,diagnostic:i.stderr}}catch(i){return{ok:!1,diagnostic:i instanceof Error?i.message:String(i)}}},gh:q,add:(s,i,l)=>h(l,r=>c(a=>_(s,i,r,a,o))),clone:(s,i,l)=>h(l,r=>c(a=>N(s,i,r,a,o))),access:s=>I(f(o)).entries[s]?.tier===1?"write":"read"},o)}export{J as runSetup,ie as setupCommand};
2
+ import{a as R,b as Y,g as _,o as N}from"./chunk-MSYRAPDK.js";import"./chunk-SALZ6WSF.js";import"./chunk-ENRFXGID.js";import{a as T,b as O,c as U,d as j}from"./chunk-X6FCXBXU.js";import{L as E,M as H,Q as L,c as P,e as I}from"./chunk-45NM23EQ.js";import"./chunk-6JUS2ULI.js";import"./chunk-HG2ILWCE.js";import"./chunk-BSRSXYDZ.js";import"./chunk-CB4ARIHR.js";import"./chunk-SSOUYKVG.js";import"./chunk-HVOXMCKE.js";import"./chunk-WMGKUERB.js";import"./chunk-UWPG5MWM.js";import{a as f}from"./chunk-73Y6T2UK.js";import{d as G,i as A}from"./chunk-XMPTFXPW.js";import"./chunk-SMXABALN.js";import"./chunk-WN5VKKJ3.js";import"./chunk-MINDIQET.js";import"./chunk-LX2I4JEH.js";import"./chunk-GEZVC4S3.js";import"./chunk-IZ66FKPC.js";import"./chunk-E4GIGM5V.js";import"./chunk-3KY7HHQU.js";import"./chunk-LD5B3QFW.js";import"./chunk-ZHAMVLQZ.js";import"./chunk-Z24SD2EJ.js";import"./chunk-AQ2OG2EF.js";import"./chunk-4IEQNX7F.js";import"./chunk-23DKB2MT.js";import"./chunk-VRIZDOO5.js";import"./chunk-ZHWU6L2G.js";import"./chunk-GJXO6FF7.js";import"./chunk-LLQWEGXD.js";import"./chunk-ZCIWQHCO.js";import"./chunk-CQDCNP7V.js";import"./chunk-7V34ZMMS.js";import"./chunk-B7ZX5HEN.js";import"./chunk-VJGWVBZR.js";import"./chunk-6PIIUAZF.js";import"./chunk-PI7OXS62.js";import"./chunk-DBMW3VUN.js";import"./chunk-KU3YHPWZ.js";import"./chunk-7V4BQSSV.js";import"./chunk-ZAQGIC33.js";import"./chunk-G4K3TP2I.js";import"./chunk-YJAQZMJT.js";import"./chunk-HYJVYYAZ.js";import"./chunk-VZ7KXRXB.js";import"./chunk-UJLULWSR.js";import"./chunk-ZCRZFAOT.js";import"./chunk-RZ4F3BHX.js";import"./chunk-A7RJQJNT.js";import"./chunk-HCBYKLMW.js";import"./chunk-33DWJV67.js";import"./chunk-FOJHSG5M.js";import"./chunk-6YGTRKDT.js";import"./chunk-FAMQ4DHU.js";import"./chunk-UR6MHSHU.js";import{existsSync as y}from"fs";import{resolve as $}from"path";import{spawn as D}from"child_process";var w=class extends Error{},m=e=>{if(e===null)throw new w;return e},u=(e,t,o)=>({value:e,label:t,detail:o});async function p(e,t,o,n=!1){for(;;){let h=m(await e.input(t,o,n)).trim();if(h)return h;e.out("Enter a value, or press Esc to leave setup.")}}async function x(e,t){e.out(`Open in your browser: ${t}`);try{await e.open(t)}catch{e.out("The browser could not open automatically. Open that address yourself, then continue here.")}}async function b(e,t){let o=await e.gitRead(t);return o.ok||e.out(j(o.diagnostic,t)),o.ok}var S=u("change","Use a different address"),C=u("storage","Choose a different storage");async function z(e,t){for(;;)try{await e.checkGit();break}catch(n){e.out(n instanceof Error?n.message:"Git 2.31 or newer is required."),m(await e.choose("Install Git, then return here",[u("open","Open Git installation instructions"),u("retry","Check again")]))==="open"&&await x(e,"https://git-scm.com/downloads")}if(await b(e,t.gitUrl))return"ok";if(!/^https:\/\/github\.com\//i.test(t.gitUrl))for(e.out("Set up Git access for this repository with your server's SSH key or credential helper. kane-cli uses the same access as Git.");;){let n=m(await e.choose("Git cannot read this repository yet.",[u("retry","Check again"),S,C]));if(n==="change"||n==="storage")return n;if(await b(e,t.gitUrl))return"ok"}for(e.out("Sign in below if you have not, or ask the owner to grant your GitHub account access.");;){let n=m(await e.choose("Sign in to access this GitHub repository",[u("login","Sign in with your browser","Use or create your GitHub account."),u("retry","I've fixed my access \u2014 check again","Ask the owner to grant your account access, or check your existing Git login."),S,C]));if(n==="change"||n==="storage")return n;if(n==="login"){if((await e.gh(["--version"])).code){e.out("Browser sign-in uses GitHub CLI, a small GitHub tool. Install it once, then return to this step. GitHub CLI is optional if you already use SSH or another Git credential helper."),m(await e.choose("GitHub CLI is not installed",[u("open","Open installation instructions"),u("retry","Check again")]))==="open"&&await x(e,"https://cli.github.com/");continue}if((await e.gh(["auth","login","--hostname","github.com","--git-protocol","https","--web"],!0)).code){e.out("Sign-in did not finish. Your repository address is still saved in this setup.");continue}for(;(await e.gh(["auth","setup-git","--hostname","github.com"])).code&&(e.out("GitHub sign-in finished, but Git could not be told to use it."),m(await e.choose("Configure Git to use your GitHub sign-in",[u("retry","Try the configuration again"),u("skip","Skip; I use SSH or another credential helper")]))!=="skip"););}if(await b(e,t.gitUrl))return"ok";e.out("A browser login alone does not grant repository permission: ask the owner to grant your GitHub account access.")}}async function k(e){if(m(await e.choose("Access to the bucket",[u("existing","Use credentials already configured on this computer","Existing kane-cli credentials or KANE_SYNC_S3_ACCESS_KEY_ID and KANE_SYNC_S3_SECRET_ACCESS_KEY."),u("keys","Enter the access keys from my storage administrator","Saved in your local kane-cli configuration, never in the shared context.")]))!=="existing")return e.out("These are bucket access keys, not your cloud account password. Your administrator must grant access to the bucket and folder you selected."),{accessKeyId:await p(e,"Access key ID"),secretAccessKey:await p(e,"Secret access key (hidden)",void 0,!0)}}async function W(e,t){let o=t?.kind??m(await e.choose("Where should your team's shared context live?",[u("github","GitHub \u2014 Recommended","Guided setup for a repository: a storage space on GitHub."),u("s3","S3-compatible storage","Use your team's existing cloud bucket and access keys."),u("folder","Folder","A local folder stays on this computer. A mounted shared drive can serve your team.")]));if(o==="github"){t||(e.out("GitHub will hold the requirements, documents and test information you publish from kane-cli. Each teammate signs in with their own account."),m(await e.choose("Choose a GitHub repository",[u("existing","Use an existing repository"),u("create","Create a repository on GitHub","Use a dedicated repository. Choose Private to limit who can see your context.")]))==="create"&&(await x(e,"https://github.com/new"),e.out("On GitHub: choose the owner and repository name, choose Private, and create the repository. Return here and paste its HTTPS address. No code or Git knowledge is needed.")));let d=await p(e,"Repository address (for example https://github.com/my-team/team-context.git)",t?.address);return{location:d,journey:{kind:o,address:d}}}if(o==="folder"){t||e.out("Everyone needs access to the same mounted drive to share through a folder. Sending a local path does not share its contents. Dropbox, iCloud, OneDrive and Google Drive sync folders are not supported.");let d=await p(e,"Folder path",t?.address);return{location:d,journey:{kind:o,address:d}}}t||e.out("Ask your storage administrator for an existing bucket and access keys. kane-cli does not create buckets or cloud permissions.");let n=t?.s3,h=await p(e,"Bucket name",n?.bucket);for(;!/^[a-zA-Z0-9.-]+$/.test(h);)e.out("Use the bucket's name, not a URL."),h=await p(e,"Bucket name");let c=await p(e,"Region",n?.region??"us-east-1"),s=m(await e.input("Folder inside the bucket (optional)",n?.prefix??"")),i=[u("aws","Amazon S3"),u("compatible","Another S3-compatible service")];n&&i.sort((d,g)=>+(g.value===n.service)-+(d.value===n.service));let l=m(await e.choose("Which storage service?",i)),r=new URLSearchParams({region:c}),a=l==="compatible"?await p(e,"Service endpoint (https://host, with an optional port)",n?.service===l?n.endpoint:void 0):void 0;return a&&r.set("endpoint",a),{location:`s3://${h}/${s.split("/").map(encodeURIComponent).join("/")}?${r}`,journey:{kind:"s3",s3:{bucket:h,region:c,prefix:s,service:l,endpoint:a}}}}function K(e){return e.kind==="dir"?"A location address contains no password: everyone who can open this folder can read it; sending the path does not send its contents.":e.kind==="s3"?"A location address contains no keys and does not grant access: grant teammates access to the bucket in your storage's console.":U(e.gitUrl??"")==="github.com"?"A location address contains no password and does not grant access. Invite teammates on GitHub.":"A location address contains no password and does not grant access: grant teammates access on your Git server."}async function J(e,t){try{e.out("Share your context: the requirements, documents and test information you add to kane-cli. A location is where your team's shared copy lives.");let o=m(await e.choose("What do you want to do?",[u("share","Share my context with my team"),u("join","Join my team's context")]));if(o==="share"&&!y(f(t)))return e.out("There is no context here to share yet. Add your documents with kane-cli context ingest <files>, then run kane-cli context sync setup again."),2;let n,h=async()=>{for(;;){let r;for(;;){let a;if(o==="join")a=await p(e,"Paste the location your teammate shared",n?.address),n={kind:"join",address:a};else{let d=await W(e,n);a=d.location,n=d.journey}try{r=E(a,t);break}catch(d){e.out(d instanceof Error?d.message:"That location could not be read.")}}if(r.kind==="fake")throw new Error("This location is only available to tests.");if(r.kind==="git"){let a=await z(e,r);if(a==="storage"&&(n=void 0),a!=="ok")continue;if(/^https:\/\/github\.com\//i.test(r.gitUrl)){let d=await e.gh(["repo","view",r.gitUrl,"--json","nameWithOwner,visibility"]),g;try{let v=JSON.parse(d.text);["PUBLIC","PRIVATE","INTERNAL"].includes(v.visibility)&&(g=v.visibility)}catch{}e.out(g?`Repository visibility: ${g.toLowerCase()}.`:"Repository visibility could not be checked automatically. Check Public/Private on GitHub before publishing.")}}return r}},c=await h(),s=c.kind==="s3"?await k(e):void 0,i="origin",l;if(o==="join")for(;l=$(t,await p(e,"Download into a new folder","team-context")),!!y(l);)e.out("That folder already exists. Choose a new folder so your current context and files stay untouched.");else{let r=P(f(t)).locations;for(;r.some(a=>a.name===i)||!/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(i);)i=await p(e,"Choose a new name for this connection","team")}for(e.out(`Location: ${c.gitUrl??c.path??c.location}`),e.out(c.kind==="git"?"Connection checks add small permanent files, commits and a scratch reference to this repository. Your own context is uploaded only by a separate publish command.":"Connection checks add small permanent files to this location. Your own context is uploaded only by a separate publish command."),m(await e.choose(o==="join"?"Connect and download team context?":"Connect this location? Your context will not be uploaded.",[u("connect",o==="join"?"Connect and download":"Connect location")]));e.out(o==="join"?"Checking access and downloading verified team context\u2026":"Checking read access and safe publishing\u2026"),(o==="join"?await e.clone(c.location,l,s):await e.add(i,c.location,s))!==0;){if(o==="join"&&y(l)){e.out(`The destination ${l} now exists after the interrupted attempt. Keep it; choose a new folder for a fresh download.`);do l=$(t,await p(e,"New download folder"));while(y(l))}let a=[u("retry","Retry this connection"),...c.kind==="s3"?[u("keys","Enter different keys")]:[],S,...o==="share"?[C]:[]],d=m(await e.choose("The connection did not finish. Your choices are kept; fix the reported issue and retry.",a));d==="keys"&&(s=await k(e)),(d==="change"||d==="storage")&&(d==="storage"&&(n=void 0),c=await h(),s=c.kind==="s3"?await k(e):void 0)}if(o==="join")e.out(`Team context downloaded into ${l}. Your previous local files were not replaced.`),e.out("Next: open that folder and run kane-cli context sync status.");else{let r=e.access(i);e.out(`Connected to ${c.gitUrl??c.path??c.location}. ${r==="write"?"You can download and publish changes.":"You can download context, but cannot publish changes."}`),e.out("Your context has not been uploaded yet."),e.out(r==="write"?`When ready, publish with kane-cli context push ${i}. This shares your context records and their referenced source documents with everyone who can read the location.`:"Ask the location owner for write access before publishing, then check the connection again."),e.out(`Share this location with teammates: ${H(c)}`),e.out(K(c))}return 0}catch(o){return o instanceof w?(e.out("Setup left. Your context has not been published. Any completed connection checks remain in the location."),3):(e.out(o instanceof Error?o.message:"Setup could not finish."),2)}}async function q(e,t=!1){return new Promise(o=>{let n=D("gh",e,{stdio:t?"inherit":["ignore","pipe","pipe"],windowsHide:!0}),h="";n.stdout?.on("data",s=>{h.length<64e3&&(h+=String(s))}),n.stderr?.on("data",()=>{});let c=setTimeout(()=>n.kill("SIGKILL"),t?3e5:2e4);n.on("error",()=>{clearTimeout(c),o({code:1,text:"GitHub CLI is unavailable"})}),n.on("close",s=>{clearTimeout(c),o({code:s??1,text:h})})})}async function ie(e,t=L(),o=process.cwd()){if(e.mode&&e.mode!=="interactive"||!G())return Y(R(e,t),t,new A("TTY_REQUIRED","guided setup needs an interactive terminal; for automation use kane-cli context sync add <name> <location> or kane-cli context clone <location> <new-folder>","run kane-cli context sync setup in a terminal"),2);let{promptSetup:n}=await import("./sync-setup-ui-XITPGSO4.js"),h=(s,i)=>i(s?{credentials:s}:{}),c=async s=>{let i=[],l=await s({...t,out:r=>i.push(r),err:r=>i.push(r)});if(l!==0)for(let r of i){if(r.startsWith("next: ")||r.startsWith("checking "))continue;let a=r.startsWith("error: ")?r.slice(7):r,d=/^([a-z][a-z0-9+.-]*:\/\/|[a-z0-9._-]+@[a-z0-9.-]+[:/]|[\/~.])/i.test(a);t.out(/^[a-z]/.test(a)&&!d?a.charAt(0).toUpperCase()+a.slice(1)+(/[.!?]$/.test(a)?"":"."):a)}return l};return J({out:t.out,choose:(s,i)=>n({title:s,choices:i}),input:(s,i,l)=>n({title:s,initial:i,secret:l}),open:async s=>{let{default:i}=await import("./open-MQLQKFAW.js");await i(s)},checkGit:()=>O(),gitRead:async s=>{try{let i=await T(["ls-remote",s],{timeout:2e4});return{ok:i.code===0,diagnostic:i.stderr}}catch(i){return{ok:!1,diagnostic:i instanceof Error?i.message:String(i)}}},gh:q,add:(s,i,l)=>h(l,r=>c(a=>_(s,i,r,a,o))),clone:(s,i,l)=>h(l,r=>c(a=>N(s,i,r,a,o))),access:s=>I(f(o)).entries[s]?.tier===1?"write":"read"},o)}export{J as runSetup,ie as setupCommand};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{f as a}from"./chunk-O2Y46A3G.js";import"./chunk-X3A4QPA3.js";import"./chunk-3MSXQU2C.js";import"./chunk-QB77LRF4.js";import"./chunk-PWNYTIVA.js";import"./chunk-4NEPHIAO.js";import"./chunk-ET5EK2CM.js";import"./chunk-OVNTCBNS.js";import"./chunk-7PCLHURF.js";import"./chunk-DLP5S3TO.js";import"./chunk-O3TXAMFW.js";import"./chunk-A4ZV2SHL.js";import"./chunk-5XVWT6UK.js";import"./chunk-45NM23EQ.js";import"./chunk-6JUS2ULI.js";import"./chunk-HG2ILWCE.js";import"./chunk-BSRSXYDZ.js";import"./chunk-CB4ARIHR.js";import"./chunk-A7IMHUFY.js";import"./chunk-4HARMERK.js";import"./chunk-A474TUCE.js";import"./chunk-WD52ZNQY.js";import"./chunk-W3USRQX6.js";import"./chunk-XZ6J3Y2W.js";import"./chunk-JUVY6PHY.js";import"./chunk-2ULYGALF.js";import"./chunk-BHSHGWBL.js";import"./chunk-S3DAAAE5.js";import"./chunk-TMH4TPMB.js";import"./chunk-LXCTV75T.js";import"./chunk-HWPWCCEV.js";import"./chunk-7O2FIZB7.js";import"./chunk-DREQ3RAA.js";import"./chunk-P4VFC6HO.js";import"./chunk-YO6SNXBJ.js";import"./chunk-MEMXFTLD.js";import"./chunk-SSOUYKVG.js";import"./chunk-HVOXMCKE.js";import"./chunk-WMGKUERB.js";import"./chunk-TAY7J5VS.js";import"./chunk-UWPG5MWM.js";import"./chunk-NVD2MXHQ.js";import"./chunk-QVMXL675.js";import"./chunk-MP6NCJFE.js";import"./chunk-7XJNYLQW.js";import"./chunk-72KYMWQ5.js";import"./chunk-CCOD4GQJ.js";import"./chunk-JQ64X2TO.js";import"./chunk-6YBH3WUW.js";import"./chunk-FYPIF3BE.js";import"./chunk-YDB72F4K.js";import"./chunk-77ZZQJLX.js";import"./chunk-JIRNI5TB.js";import"./chunk-UTM7D4PI.js";import"./chunk-EEOAU43D.js";import"./chunk-LWCP4GLY.js";import"./chunk-DXLZCJH5.js";import"./chunk-UCVP7ZY4.js";import"./chunk-5Y2G4NC7.js";import"./chunk-IINZZ4BZ.js";import"./chunk-TDPWFYTJ.js";import"./chunk-73Y6T2UK.js";import"./chunk-VE4HLIGA.js";import"./chunk-XMPTFXPW.js";import"./chunk-M7Y5GGVJ.js";import"./chunk-GJ7MO2FW.js";import"./chunk-Z36KVIRR.js";import"./chunk-Q4JV4U65.js";import"./chunk-5MFPQYW3.js";import"./chunk-BHQIH2FE.js";import"./chunk-ZO3ZAMUU.js";import"./chunk-VE3SUJMA.js";import"./chunk-ABMM37L2.js";import"./chunk-RFHMDQXZ.js";import"./chunk-PC22QRIY.js";import"./chunk-44SIFDNY.js";import"./chunk-6LEHGRRG.js";import"./chunk-BJT6PZXL.js";import"./chunk-5D7ENQTQ.js";import"./chunk-KN7GZWKK.js";import"./chunk-V3OZJO7Y.js";import"./chunk-5KJU4MG4.js";import"./chunk-Y6Y6RAY4.js";import"./chunk-75FF7J5R.js";import"./chunk-226AGYHB.js";import"./chunk-O5KTMDTH.js";import"./chunk-SMXABALN.js";import"./chunk-73HMW2WA.js";import"./chunk-6K5BEEAJ.js";import"./chunk-IB5WG5YY.js";import"./chunk-I52NWH4U.js";import"./chunk-MMBBQ4OZ.js";import"./chunk-HX5OLRKU.js";import"./chunk-TZXXJWHA.js";import"./chunk-SXRHKXSE.js";import{a as o}from"./chunk-WN5VKKJ3.js";import"./chunk-5WLXAQ4H.js";import"./chunk-2QKBXRLI.js";import"./chunk-4HYPMGDF.js";import"./chunk-Z7S3IWUX.js";import"./chunk-4JOD47QI.js";import"./chunk-ZDQYGLCZ.js";import"./chunk-2GEAKFAV.js";import"./chunk-FCD3NYOM.js";import"./chunk-3G2LSTK5.js";import"./chunk-32MFECUA.js";import"./chunk-4IEQNX7F.js";import"./chunk-23DKB2MT.js";import"./chunk-VRIZDOO5.js";import"./chunk-ZHWU6L2G.js";import"./chunk-REKHAN53.js";import"./chunk-FOLUB336.js";import"./chunk-GJXO6FF7.js";import"./chunk-LLQWEGXD.js";import"./chunk-ZCIWQHCO.js";import"./chunk-XB6BJPDL.js";import"./chunk-CQDCNP7V.js";import"./chunk-EHB55V23.js";import"./chunk-TD6GCEIK.js";import"./chunk-7V34ZMMS.js";import"./chunk-B7ZX5HEN.js";import"./chunk-W2HRX3DR.js";import"./chunk-PVN64537.js";import"./chunk-H4TIVILC.js";import"./chunk-GFLB2SHW.js";import"./chunk-2TVPA3LL.js";import"./chunk-VJGWVBZR.js";import"./chunk-22PIMG52.js";import"./chunk-RQKMSNEU.js";import"./chunk-4C7WVQOD.js";import"./chunk-QXQ7KVEN.js";import"./chunk-OKA6FPJM.js";import"./chunk-B57ZRHEQ.js";import"./chunk-QSCXXNC2.js";import"./chunk-6PIIUAZF.js";import"./chunk-PI7OXS62.js";import"./chunk-DBMW3VUN.js";import"./chunk-KU3YHPWZ.js";import"./chunk-7V4BQSSV.js";import"./chunk-ZAQGIC33.js";import"./chunk-VO66KP2W.js";import"./chunk-G4K3TP2I.js";import"./chunk-YJAQZMJT.js";import"./chunk-HYJVYYAZ.js";import"./chunk-VZ7KXRXB.js";import"./chunk-GMTHZUZ3.js";import"./chunk-UJLULWSR.js";import"./chunk-ZCRZFAOT.js";import"./chunk-FI2DVNRT.js";import"./chunk-4QTH7VYE.js";import"./chunk-RZ4F3BHX.js";import"./chunk-E47GFYXA.js";import"./chunk-2XW33VOK.js";import"./chunk-7HO4NX5W.js";import"./chunk-A7RJQJNT.js";import"./chunk-K75WIRI5.js";import"./chunk-XHFU5TGS.js";import"./chunk-M3TFOFUQ.js";import{a as t}from"./chunk-HCBYKLMW.js";import{c as n}from"./chunk-33DWJV67.js";import"./chunk-FOJHSG5M.js";import"./chunk-6YGTRKDT.js";import"./chunk-FAMQ4DHU.js";import{e as r}from"./chunk-UR6MHSHU.js";var e=r(t(),1);async function p(i){let c=i.scenarioLimit!==void 0||i.perScenarioLimit!==void 0?{scenarioLimit:i.scenarioLimit,perScenarioLimit:i.perScenarioLimit}:void 0,{waitUntilExit:m}=n((0,e.jsx)(o,{children:(0,e.jsx)(a,{initialChatMode:"generate",initialObjective:i.objective,initialGenerateLimits:c})}),{exitOnCtrlC:!1});await m()}export{p as runGenerate};