@testmuai/kane-cli 0.8.9 → 0.8.11

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 (234) hide show
  1. package/dist/{ChatSurface-HXCRGPSE.js → ChatSurface-YFJDAXOG.js} +1 -1
  2. package/dist/{ChromeProfilePicker-PJS4NGEC.js → ChromeProfilePicker-PUCZN6WU.js} +1 -1
  3. package/dist/{CliFeedbackPrompt-Q56VKWKM.js → CliFeedbackPrompt-JAIB5MHS.js} +1 -1
  4. package/dist/{CliUploadProgress-TMVTKNOT.js → CliUploadProgress-53LQMQJD.js} +1 -1
  5. package/dist/{ConfigView-Y7ZVYT2C.js → ConfigView-7HFP4OXS.js} +1 -1
  6. package/dist/EvidenceViewOffer-2T2ZGHIF.js +2 -0
  7. package/dist/FolderPicker-LTQW4YNR.js +2 -0
  8. package/dist/{InfoBox-IDJYGPXF.js → InfoBox-62YG3YNQ.js} +1 -1
  9. package/dist/{LinksBox-5XNJ3UJJ.js → LinksBox-6NS3GHWO.js} +1 -1
  10. package/dist/{ProfilesView-U73QBC5W.js → ProfilesView-HIKK2HPC.js} +1 -1
  11. package/dist/{ProjectPicker-KCE2VZCO.js → ProjectPicker-2CJMO5TD.js} +1 -1
  12. package/dist/{SaveSessionPrompt-3FHLIRLS.js → SaveSessionPrompt-4DTPZSXD.js} +1 -1
  13. package/dist/SingleShotApp-KXZF5ZJM.js +2 -0
  14. package/dist/{SummaryBox-GKHU4C4H.js → SummaryBox-A6LKKQXJ.js} +1 -1
  15. package/dist/TestMdRunView-6X6W5YAP.js +2 -0
  16. package/dist/{TestrunEvidenceTable-INNZCGTM.js → TestrunEvidenceTable-7SCCTZPH.js} +1 -1
  17. package/dist/{WhoamiView-PSL7PUVT.js → WhoamiView-PDMQ6F5N.js} +1 -1
  18. package/dist/{app-download-MBUJGT3R.js → app-download-K2ELUXWR.js} +1 -1
  19. package/dist/{auth-TYG473Z4.js → auth-5WJSFLCP.js} +1 -1
  20. package/dist/{binary-QQXWA35Q.js → binary-QVQRWQFK.js} +1 -1
  21. package/dist/{bind-WJ5UEMMZ.js → bind-5WELCZ4S.js} +3 -3
  22. package/dist/{bootstrap-MYG4TJVF.js → bootstrap-3LNHRDQH.js} +1 -1
  23. package/dist/bridge-WFSSMJ57.js +2 -0
  24. package/dist/{changelog-N4L5ZUGF.js → changelog-TK6DWFVW.js} +1 -1
  25. package/dist/{chat-committer-K3NOTLOU.js → chat-committer-MAW25ICC.js} +1 -1
  26. package/dist/chat-controller-6GW2HSJP.js +2 -0
  27. package/dist/{chunk-ZAKX5BN6.js → chunk-2E55VQYA.js} +1 -1
  28. package/dist/{chunk-QHUNFH5P.js → chunk-2KQF6WLX.js} +4 -4
  29. package/dist/{chunk-PH4RABYU.js → chunk-2QSG5ZG6.js} +1 -1
  30. package/dist/{chunk-QS3DXKZN.js → chunk-2ZBY2GME.js} +1 -1
  31. package/dist/{chunk-54JZ6VEW.js → chunk-3D7VYEDP.js} +1 -1
  32. package/dist/{chunk-F5BI3ALG.js → chunk-3FJNTRAS.js} +1 -1
  33. package/dist/{chunk-DUEROGOF.js → chunk-3PMEHGH3.js} +1 -1
  34. package/dist/chunk-47WY2637.js +84 -0
  35. package/dist/{chunk-UEIQTXB6.js → chunk-4AZ7IG2A.js} +1 -1
  36. package/dist/{chunk-Z2DT2QMX.js → chunk-4FXSDPQW.js} +1 -1
  37. package/dist/{chunk-6ZNRPDLP.js → chunk-4SXJKDHO.js} +2 -2
  38. package/dist/{chunk-OR6M5HCV.js → chunk-4VYWTTT4.js} +2 -2
  39. package/dist/{chunk-R5PIIYN2.js → chunk-4VZRBBLF.js} +1 -1
  40. package/dist/{chunk-GWSGTZMK.js → chunk-5LEO463W.js} +1 -1
  41. package/dist/{chunk-7RAIRUXO.js → chunk-5NBT5IVT.js} +1 -1
  42. package/dist/{chunk-HKCZ67AT.js → chunk-6DOS5CJ5.js} +1 -1
  43. package/dist/{chunk-N7Z7BQYO.js → chunk-6GH4DRKR.js} +1 -1
  44. package/dist/{chunk-27P7PJAL.js → chunk-7B7OSHPX.js} +1 -1
  45. package/dist/{chunk-WH5RVDD6.js → chunk-7HUJVIMO.js} +1 -1
  46. package/dist/{chunk-NTEI2O3O.js → chunk-7KRCBN6X.js} +2 -2
  47. package/dist/{chunk-XPFFH2PC.js → chunk-7P3JGF2X.js} +1 -1
  48. package/dist/{chunk-AROBXG66.js → chunk-A4BDLZOD.js} +1 -1
  49. package/dist/{chunk-SJBIXLL3.js → chunk-A76UL3EN.js} +1 -1
  50. package/dist/{chunk-M7D7EHNN.js → chunk-ASK4AZFC.js} +1 -1
  51. package/dist/{chunk-CCEXSCTN.js → chunk-AXW3WDFO.js} +1 -1
  52. package/dist/{chunk-IVQX3AKL.js → chunk-B7K5WOOU.js} +1 -1
  53. package/dist/{chunk-VDKGMVXZ.js → chunk-B7TJIUKZ.js} +1 -1
  54. package/dist/{chunk-H6KL3FSB.js → chunk-BE4FBVKY.js} +1 -1
  55. package/dist/chunk-BHSHGWBL.js +2 -0
  56. package/dist/chunk-CABRAZOL.js +5 -0
  57. package/dist/{chunk-H5TNYYZW.js → chunk-CBLUNSF4.js} +1 -1
  58. package/dist/{chunk-O3RRCPIU.js → chunk-CL3AMEK6.js} +1 -1
  59. package/dist/{chunk-ZDAO5D6D.js → chunk-CQKKDIKA.js} +1 -1
  60. package/dist/{chunk-IBPF5IM5.js → chunk-CRPBARFG.js} +1 -1
  61. package/dist/chunk-DEUDRSU7.js +2 -0
  62. package/dist/{chunk-IJYV3KKD.js → chunk-DHWS7SLT.js} +2 -2
  63. package/dist/{chunk-ZBJAYCPS.js → chunk-DJJO4IHY.js} +1 -1
  64. package/dist/{chunk-KKBID6TD.js → chunk-DLJIML73.js} +1 -1
  65. package/dist/{chunk-EV64VI66.js → chunk-DP7GPS6S.js} +1 -1
  66. package/dist/chunk-F7R6A6P5.js +4 -0
  67. package/dist/{chunk-CJD3EEPT.js → chunk-FIODM24X.js} +1 -1
  68. package/dist/{chunk-2DKJZPIH.js → chunk-FQRWYXFG.js} +1 -1
  69. package/dist/{chunk-6FCPS2VT.js → chunk-FYLMTZ3J.js} +1 -1
  70. package/dist/{chunk-ZHB7V3NY.js → chunk-G5ZGEZCA.js} +1 -1
  71. package/dist/{chunk-367NASYK.js → chunk-GMXM4WHF.js} +1 -1
  72. package/dist/{chunk-VSEWQEM5.js → chunk-GSNGC7HI.js} +1 -1
  73. package/dist/{chunk-22HCCSL7.js → chunk-GV5BX2IQ.js} +1 -1
  74. package/dist/{chunk-LRHSWJDR.js → chunk-HFRMJP2P.js} +1 -1
  75. package/dist/chunk-HJBORIFP.js +26 -0
  76. package/dist/{chunk-WIAZN7G4.js → chunk-HULEZ3D3.js} +1 -1
  77. package/dist/{chunk-JPZHCB4Z.js → chunk-IX4FH5W6.js} +1 -1
  78. package/dist/{chunk-QDE2BBAK.js → chunk-JAO7TZBV.js} +1 -1
  79. package/dist/{chunk-MJHLQKQC.js → chunk-JJJREAFQ.js} +1 -1
  80. package/dist/{chunk-6UNXON3J.js → chunk-K6BWPGBO.js} +1 -1
  81. package/dist/chunk-KRL2BDI5.js +8 -0
  82. package/dist/{chunk-R7GMVPAF.js → chunk-M3Q7IQMS.js} +1 -1
  83. package/dist/{chunk-WHMMOMUY.js → chunk-M7CGNE2D.js} +4 -4
  84. package/dist/{chunk-2YQ6TW77.js → chunk-NBXYL2JT.js} +6 -6
  85. package/dist/chunk-NGASEXVA.js +27 -0
  86. package/dist/{chunk-VQFJM7VP.js → chunk-NLSR2IFN.js} +1 -1
  87. package/dist/{chunk-H4WIA4IP.js → chunk-NP3VGFZM.js} +1 -1
  88. package/dist/{chunk-6MJGCETZ.js → chunk-NVRXDLJN.js} +1 -1
  89. package/dist/{chunk-OEH4LU5L.js → chunk-NYUMJDCE.js} +1 -1
  90. package/dist/chunk-O7RB4X6I.js +21 -0
  91. package/dist/{chunk-COJGXGKZ.js → chunk-OC7TJTQG.js} +1 -1
  92. package/dist/{chunk-BOZODWIZ.js → chunk-OGJ6ZSLC.js} +1 -1
  93. package/dist/{chunk-EEFZXZTZ.js → chunk-OKBEMFAW.js} +1 -1
  94. package/dist/{chunk-NVNPXOOC.js → chunk-OKCULEBD.js} +1 -1
  95. package/dist/{chunk-XMTSHHYQ.js → chunk-OXHMUZJV.js} +1 -1
  96. package/dist/chunk-OZMYKG6E.js +6 -0
  97. package/dist/chunk-PDXZROJM.js +2 -0
  98. package/dist/{chunk-5G22NOZK.js → chunk-QHSF2CXK.js} +1 -1
  99. package/dist/{chunk-IANCFSSL.js → chunk-QIRZBOKA.js} +1 -1
  100. package/dist/{chunk-W3Z7AZNT.js → chunk-R4EGL7VM.js} +1 -1
  101. package/dist/{chunk-KAZGHWGK.js → chunk-S63XGGBE.js} +1 -1
  102. package/dist/{chunk-ME3DGP7G.js → chunk-SNKFWPEM.js} +2 -2
  103. package/dist/chunk-T4OJX2GZ.js +15 -0
  104. package/dist/chunk-TB2CCKL7.js +2 -0
  105. package/dist/{chunk-FC6DEFUP.js → chunk-TSW5A7W3.js} +1 -1
  106. package/dist/{chunk-UH2ZTX4E.js → chunk-TYRTD5DD.js} +1 -1
  107. package/dist/{chunk-SV5ZTCQA.js → chunk-URLZULC7.js} +1 -1
  108. package/dist/{chunk-TJR4R45C.js → chunk-VGLY4HWA.js} +1 -1
  109. package/dist/{chunk-IDQBMC3B.js → chunk-VUOAFV27.js} +1 -1
  110. package/dist/{chunk-DKUD2D5Y.js → chunk-W4IRHQGO.js} +9 -9
  111. package/dist/{chunk-P2VERPOP.js → chunk-W7NI6JCF.js} +1 -1
  112. package/dist/chunk-WD52ZNQY.js +2 -0
  113. package/dist/chunk-WRVDIZAI.js +6 -0
  114. package/dist/{chunk-DGNVKMGN.js → chunk-X6WB2QTT.js} +1 -1
  115. package/dist/{chunk-IPZFZUJX.js → chunk-XB7EMX6J.js} +1 -1
  116. package/dist/{chunk-KRKGZ2ZW.js → chunk-XS2LZFCH.js} +1 -1
  117. package/dist/{chunk-34VSIQNO.js → chunk-XYSFPVJX.js} +1 -1
  118. package/dist/chunk-Y4ODYIOP.js +6 -0
  119. package/dist/{chunk-O5U6EAL3.js → chunk-YELGHSVH.js} +1 -1
  120. package/dist/{chunk-OME5EJ5X.js → chunk-YQ4MRF57.js} +4 -4
  121. package/dist/{chunk-AOB2ZX45.js → chunk-YSNBXUM6.js} +1 -1
  122. package/dist/{chunk-KGKJU27A.js → chunk-Z4QLCWLB.js} +1 -1
  123. package/dist/{chunk-6S426ODE.js → chunk-Z6GMZOVL.js} +3 -3
  124. package/dist/{chunk-IWVA37B6.js → chunk-ZES42R57.js} +1 -1
  125. package/dist/{chunk-TN4SXGAP.js → chunk-ZMJD3CI7.js} +1 -1
  126. package/dist/{committer-C6UCDYMC.js → committer-42AFWMEX.js} +1 -1
  127. package/dist/{config-ZDGCZZT3.js → config-KU2UICMC.js} +1 -1
  128. package/dist/{cover-cmd-5LPHIOSI.js → cover-cmd-HAOBK2IC.js} +1 -1
  129. package/dist/{credentials-YEWA7HXA.js → credentials-BEC4I5SE.js} +1 -1
  130. package/dist/{deps-bundle-JQUW73W5.js → deps-bundle-EY5T7OH3.js} +1 -1
  131. package/dist/{deps-resolve-RXF3JWAP.js → deps-resolve-MPLFFCZZ.js} +1 -1
  132. package/dist/design-committer-2BQVZPO4.js +2 -0
  133. package/dist/dispatch-NE35HS5F.js +2 -0
  134. package/dist/{doctor-F7R4WUSI.js → doctor-JBXA6WNL.js} +1 -1
  135. package/dist/{docx-convert-JMUMT5C4.js → docx-convert-BIV5T7F5.js} +1 -1
  136. package/dist/{dossier-Y6TJWFZU.js → dossier-WSWXZAPL.js} +1 -1
  137. package/dist/effective-decisions-UNE2TFVA.js +2 -0
  138. package/dist/{evidence-F3CQJQIB.js → evidence-MJV3PY2J.js} +1 -1
  139. package/dist/evolve-cmd-I4Z6IPIM.js +2 -0
  140. package/dist/explain-O3A2HZWD.js +2 -0
  141. package/dist/{explain-cmd-RMJPXD4U.js → explain-cmd-BXFR5DB6.js} +1 -1
  142. package/dist/{explain-cmd-XCRO4AS6.js → explain-cmd-IRQ2YX5L.js} +1 -1
  143. package/dist/{extract-bind-PH3VB7PY.js → extract-bind-PPMY4FFA.js} +3 -3
  144. package/dist/{extract-cmd-HSESPCTL.js → extract-cmd-RHVLPNQB.js} +2 -2
  145. package/dist/{feeder-IOR3XRNF.js → feeder-52VBZY3R.js} +1 -1
  146. package/dist/{gaps-cmd-JIUM5YDY.js → gaps-cmd-MSDGU6OU.js} +1 -1
  147. package/dist/{generate-headless-Z5YF7UHX.js → generate-headless-NSK32S53.js} +2 -2
  148. package/dist/index.js +115 -115
  149. package/dist/ingest-WTPY2VLS.js +2 -0
  150. package/dist/ingest-cmd-GOPW3SNF.js +2 -0
  151. package/dist/install-BDHZVEY4.js +2 -0
  152. package/dist/{interactive-bind-HZG2KCTX.js → interactive-bind-4FNW3OYT.js} +4 -4
  153. package/dist/{lifecycle-cmd-KSMETBPP.js → lifecycle-cmd-HYNG5KH6.js} +1 -1
  154. package/dist/{list-cmd-V3HJ5K4O.js → list-cmd-Y4WEOT3E.js} +1 -1
  155. package/dist/{list-commands-BHQHPHOH.js → list-commands-CJCEW7MQ.js} +1 -1
  156. package/dist/{logical-ids-MLXAH45L.js → logical-ids-N3UZACB4.js} +1 -1
  157. package/dist/login-flow-DLG2WHSZ.js +2 -0
  158. package/dist/{maintenance-cmd-VFYGKY3X.js → maintenance-cmd-UJNH47SG.js} +1 -1
  159. package/dist/{mobile-prompts-ELBW35KK.js → mobile-prompts-SJZVJWSB.js} +1 -1
  160. package/dist/persist-recorded-session-FWBAOQEF.js +3 -0
  161. package/dist/{phase-seed-BMOSAA74.js → phase-seed-2WI7KUYO.js} +1 -1
  162. package/dist/pipeline-B2TYZBMB.js +2 -0
  163. package/dist/prepare-target-JGVB7OKC.js +2 -0
  164. package/dist/readmodel-YDLGQDMH.js +2 -0
  165. package/dist/reconcile-cmd-6ILIXD3U.js +2 -0
  166. package/dist/{reconcile-deps-RX66LB4B.js → reconcile-deps-GMQA6ULT.js} +2 -2
  167. package/dist/{reconcile-engine-OEDO57U7.js → reconcile-engine-XLLYS5ZB.js} +1 -1
  168. package/dist/{recording-banner-COX2HBLL.js → recording-banner-CQBXZMT3.js} +1 -1
  169. package/dist/{records-JLS63SDI.js → records-EW4PIJ5W.js} +1 -1
  170. package/dist/registry-AA5YIO5Y.js +2 -0
  171. package/dist/{replay-policy-CVQ6OJX5.js → replay-policy-A62KXE6Y.js} +1 -1
  172. package/dist/{require-project-folder-XFUJYJEA.js → require-project-folder-K3E3QIOZ.js} +1 -1
  173. package/dist/{resolve-run-intent-24D3BV2J.js → resolve-run-intent-3CENNCF3.js} +1 -1
  174. package/dist/{resolver-ITA6TGPJ.js → resolver-PSNP72H4.js} +1 -1
  175. package/dist/{revert-PRR3D4XM.js → revert-RXHWWUMQ.js} +1 -1
  176. package/dist/{review-cmd-SAGIKWEW.js → review-cmd-JUOWTME4.js} +1 -1
  177. package/dist/run-6CMGGU2W.js +2 -0
  178. package/dist/run-PZIYMD35.js +2 -0
  179. package/dist/{run-test-md-U5PSCPZU.js → run-test-md-XBM6RMCI.js} +2 -2
  180. package/dist/{sessions-cmd-VDQGRBEM.js → sessions-cmd-PGE6LP2W.js} +1 -1
  181. package/dist/{skill-installer-STKFBIY4.js → skill-installer-FBOPYFYS.js} +1 -1
  182. package/dist/{spawner-R76ROCR2.js → spawner-URQ5OAY7.js} +1 -1
  183. package/dist/{structured-answers-YAVW65G4.js → structured-answers-BZWJUX22.js} +1 -1
  184. package/dist/tcg-generate-BPLQ7WJ5.js +2 -0
  185. package/dist/testmd-actions-WJS2YM7B.js +2 -0
  186. package/dist/testmd-sync-TPUBEORI.js +2 -0
  187. package/dist/token-refresh-IT4LVE2H.js +2 -0
  188. package/dist/{validate-basic-BPJVV64Y.js → validate-basic-BXBHTTTO.js} +1 -1
  189. package/dist/verdicts-J5MJHUGG.js +2 -0
  190. package/dist/{version-check-PWHLDMPD.js → version-check-BGHE3LAK.js} +1 -1
  191. package/dist/{view-cmd-SXXNDZIC.js → view-cmd-XD5ENSML.js} +1 -1
  192. package/dist/{walk-session-OMUB7DPJ.js → walk-session-EYBUURRA.js} +1 -1
  193. package/dist/{with-telemetry-WI5FZFEK.js → with-telemetry-L3SO6J3L.js} +1 -1
  194. package/package.json +11 -11
  195. package/dist/EvidenceViewOffer-XV3WF2EC.js +0 -2
  196. package/dist/FolderPicker-UGHFCPUL.js +0 -2
  197. package/dist/SingleShotApp-ECA24PKW.js +0 -2
  198. package/dist/TestMdRunView-KLMMXQCN.js +0 -2
  199. package/dist/bridge-S3WZ4TH2.js +0 -2
  200. package/dist/chat-controller-YJCNU76T.js +0 -2
  201. package/dist/chunk-7UCICMK7.js +0 -5
  202. package/dist/chunk-AARF24Z3.js +0 -26
  203. package/dist/chunk-BVON52QL.js +0 -6
  204. package/dist/chunk-D5MK4WTK.js +0 -26
  205. package/dist/chunk-DWHXXPDX.js +0 -2
  206. package/dist/chunk-EKCGZXZE.js +0 -2
  207. package/dist/chunk-FT23VFSR.js +0 -71
  208. package/dist/chunk-HPBI3P6I.js +0 -6
  209. package/dist/chunk-IPEA7ZOF.js +0 -8
  210. package/dist/chunk-OLKHUNSQ.js +0 -21
  211. package/dist/chunk-TJLGHGUO.js +0 -7
  212. package/dist/chunk-W5BTYVZD.js +0 -2
  213. package/dist/chunk-WHEWZR2C.js +0 -15
  214. package/dist/design-committer-UPC6NZUF.js +0 -2
  215. package/dist/dispatch-TRYJZWJE.js +0 -2
  216. package/dist/effective-decisions-DRM3JSR4.js +0 -2
  217. package/dist/evolve-cmd-ICTXNYU4.js +0 -2
  218. package/dist/explain-3HAZY7Q6.js +0 -2
  219. package/dist/ingest-TTUQ7UDK.js +0 -2
  220. package/dist/ingest-cmd-SNPNVPIO.js +0 -2
  221. package/dist/install-VBUDO2YW.js +0 -2
  222. package/dist/login-flow-TWGSFMWW.js +0 -2
  223. package/dist/persist-recorded-session-DXUJXHC5.js +0 -3
  224. package/dist/pipeline-ULKJX3FG.js +0 -2
  225. package/dist/prepare-target-M656XQLU.js +0 -2
  226. package/dist/readmodel-TDRFVDVI.js +0 -2
  227. package/dist/reconcile-cmd-DBOUGUEB.js +0 -2
  228. package/dist/registry-PAVGNBIB.js +0 -2
  229. package/dist/run-IHELHWA2.js +0 -2
  230. package/dist/run-OTSAYPBQ.js +0 -2
  231. package/dist/tcg-generate-VJARWDD4.js +0 -2
  232. package/dist/testmd-actions-PXGLZV5L.js +0 -2
  233. package/dist/token-refresh-ZFT457VI.js +0 -2
  234. package/dist/verdicts-56ZZN3E4.js +0 -2
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as l}from"./chunk-DPUV6OSP.js";import{a as c}from"./chunk-NLCCBXXV.js";import{a}from"./chunk-RZ4F3BHX.js";var h=class{constructor(e,t,r,s){this.controllerBaseUrl=e;this.getOAuthToken=t;this.directBasicAuth=r;this.log=s}_cached=null;_revoked=!1;_lastError=null;revoke(){this._revoked=!0,this._cached=null}prime(e){this._revoked||(this._cached=e)}get revoked(){return this._revoked}get cached(){return this._cached}get lastError(){return this._lastError}async resolve(e=!1){if(this._cached&&!e)return this._cached;try{let t;if(this.directBasicAuth)t=new l(this.controllerBaseUrl,{username:this.directBasicAuth.username,accessKey:this.directBasicAuth.access_key});else{let s=await this.getOAuthToken();if(!s)return null;t=new l(this.controllerBaseUrl,s)}let r=await t.getTmsCredentials();this.directBasicAuth&&!r.access_key&&(r.access_key=this.directBasicAuth.access_key),this._cached=r,this._lastError=null;try{let[{refreshIdentitySnapshot:s},{telemetryEnvName:n}]=await Promise.all([import("./identity-ADZ4PAJF.js"),import("./bootstrap-MYG4TJVF.js")]);await s(n(),r)}catch{}return this.log?.("info","AUTH_RESOLVE_OK","Auth resolved",{username:r.username,org_id:r.org_id,user_id:r.user_id}),r}catch(t){return this._lastError=t instanceof Error?t:new Error(String(t)),this.log?.("warn","AUTH_RESOLVE_FAILED","Auth resolve failed",{error:this._lastError.message}),null}}async fetch(e,t={}){if(this._revoked)throw new Error("Resolver has been revoked \u2014 identity changed");let r=await this.resolve();if(!r)throw new Error("Not authenticated \u2014 no credentials resolved");let s=i=>({...t,headers:{...t.headers,Authorization:c(i.username,i.access_key)}}),n=await a(e,s(r));if(n.status===401){if(this._revoked)throw new Error("Resolver has been revoked \u2014 identity changed");this.log?.("warn","AUTH_RESOLVE_401","Got 401, re-resolving",{url:e});let i=await this.resolve(!0);if(!i)throw new Error("Re-authentication failed after 401");return a(e,s(i))}return n}};function _(o){if(!o)return"network";let e=/failed:\s*(\d{3})\b/.exec(o.message)?.[1];return e==="401"||e==="403"?"auth":e?"server":"network"}export{h as a,_ as b};
2
+ import{a as l}from"./chunk-DPUV6OSP.js";import{a as c}from"./chunk-NLCCBXXV.js";import{a}from"./chunk-RZ4F3BHX.js";var h=class{constructor(e,t,r,s){this.controllerBaseUrl=e;this.getOAuthToken=t;this.directBasicAuth=r;this.log=s}_cached=null;_revoked=!1;_lastError=null;revoke(){this._revoked=!0,this._cached=null}prime(e){this._revoked||(this._cached=e)}get revoked(){return this._revoked}get cached(){return this._cached}get lastError(){return this._lastError}async resolve(e=!1){if(this._cached&&!e)return this._cached;try{let t;if(this.directBasicAuth)t=new l(this.controllerBaseUrl,{username:this.directBasicAuth.username,accessKey:this.directBasicAuth.access_key});else{let s=await this.getOAuthToken();if(!s)return null;t=new l(this.controllerBaseUrl,s)}let r=await t.getTmsCredentials();this.directBasicAuth&&!r.access_key&&(r.access_key=this.directBasicAuth.access_key),this._cached=r,this._lastError=null;try{let[{refreshIdentitySnapshot:s},{telemetryEnvName:n}]=await Promise.all([import("./identity-ADZ4PAJF.js"),import("./bootstrap-3LNHRDQH.js")]);await s(n(),r)}catch{}return this.log?.("info","AUTH_RESOLVE_OK","Auth resolved",{username:r.username,org_id:r.org_id,user_id:r.user_id}),r}catch(t){return this._lastError=t instanceof Error?t:new Error(String(t)),this.log?.("warn","AUTH_RESOLVE_FAILED","Auth resolve failed",{error:this._lastError.message}),null}}async fetch(e,t={}){if(this._revoked)throw new Error("Resolver has been revoked \u2014 identity changed");let r=await this.resolve();if(!r)throw new Error("Not authenticated \u2014 no credentials resolved");let s=i=>({...t,headers:{...t.headers,Authorization:c(i.username,i.access_key)}}),n=await a(e,s(r));if(n.status===401){if(this._revoked)throw new Error("Resolver has been revoked \u2014 identity changed");this.log?.("warn","AUTH_RESOLVE_401","Got 401, re-resolving",{url:e});let i=await this.resolve(!0);if(!i)throw new Error("Re-authentication failed after 401");return a(e,s(i))}return n}};function _(o){if(!o)return"network";let e=/failed:\s*(\d{3})\b/.exec(o.message)?.[1];return e==="401"||e==="403"?"auth":e?"server":"network"}export{h as a,_ as b};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{homedir as a}from"os";import{join as t}from"path";var m="0.8.11";var e=t(a(),".testmuai","kaneai"),d=t(e,"profiles"),g=t(e,"tui-config.json"),h=t(e,"media"),b="https://registry.npmjs.org/@testmuai/kane-cli",A="https://api.github.com/repos/LambdaTest/kane-cli/releases",n="@testmuai/kane-cli-skill",_=`https://registry.npmjs.org/${n}`,r="kane-cli",L=[{dir:t(a(),".claude","skills",r),agent:"Claude Code"},{dir:t(a(),".agents","skills",r),agent:"Codex CLI"},{dir:t(a(),".gemini","skills",r),agent:"Gemini CLI"}],x="https://dd-proxy.lambdatest.com/intake/kane-cli",U="https://kaneai-playground.lambdatest.io",u=9222,R=9230,I=t(e,"chrome-profiles"),o=t(e,"hints"),E=t(o,"state.json");function C(s){return t(o,`catalog-${s}.json`)}var c="127.0.0.1",T=18392,S=18400,i="/callback";function f(s){return`http://${c}:${s}${i}`}var B="KANE CLI",N="*",P={prod:{authBaseUrl:"https://auth.lambdatest.com",consentUrl:"https://accounts.lambdatest.com",controllerBaseUrl:"https://kaneai-api.lambdatest.com/v16-controller/v1",tmsBaseUrl:"https://test-manager-api.lambdatest.com/api",testGeneratorBaseUrl:"https://test-manager-api.lambdatest.com",secretsBaseUrl:"https://api-hyperexecute.lambdatest.com",testManagerUiUrl:"https://test-manager.lambdatest.com",shareApiBaseUrl:"https://api.lambdatest.com",v16ServerHost:"https://kaneai-api.lambdatest.com/v16-server",evidenceViewerUrl:"https://evidence.lambdatest.com",mediaArtefactsHost:"prod-mobile-artefacts.lambdatest.com",mobileAppBaseUrl:"https://api.lambdatest.com"},stage:{authBaseUrl:"https://stage-auth.lambdatestinternal.com",consentUrl:"https://stage-accounts.lambdatestinternal.com",controllerBaseUrl:"https://auteur-stage-automind.lambdatestinternal.com/v16-controller/v1",tmsBaseUrl:"https://stage-test-manager-api.lambdatestinternal.com/api",testGeneratorBaseUrl:"https://stage-test-manager-api.lambdatestinternal.com",secretsBaseUrl:"https://api-stage-hyperexecute.lambdatestinternal.com",testManagerUiUrl:"https://stage-test-manager.lambdatestinternal.com",shareApiBaseUrl:"https://stage-api.lambdatestinternal.com",v16ServerHost:"https://auteur-stage-automind.lambdatestinternal.com/v16-server",evidenceViewerUrl:"https://stage-evidence.lambdatestinternal.com",mediaArtefactsHost:"stage-mobile-artefacts.lambdatestinternal.com",mobileAppBaseUrl:"https://stage-api.lambdatestinternal.com"}},O={orange:"#ff9500",generateAccent:"#0d9488",assuranceAccent:"#b388ff",purple:"#b388ff",secondary:"#888888",dim:"#666666",muted:"#444444",green:"#4ade80",red:"#ef4444",amber:"#fbbf24"};export{m as a,e as b,g as c,h as d,b as e,A as f,n as g,L as h,x as i,U as j,u as k,R as l,I as m,E as n,C as o,c as p,T as q,S as r,i as s,f as t,B as u,N as v,P as w,O as x};
@@ -1,7 +1,7 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as k}from"./chunk-IBPF5IM5.js";import{a as m}from"./chunk-BPMSNGXQ.js";import{r as a}from"./chunk-RSSOJ3L2.js";import{a as y}from"./chunk-H6KL3FSB.js";import{a as h}from"./chunk-6MJGCETZ.js";var $=10,u=200,N=1e4,S=1e6;function T(t,e,r="streaming"){let n=r==="full-fetch"?S:N,o=$,i=0;if(t!==void 0){let s=Number(t);if(!Number.isInteger(s)||s<1||s>u)return{error:`--limit must be an integer in [1, ${u}] (got "${t}")`};o=s}if(e!==void 0){let s=Number(e);if(!Number.isInteger(s)||s<0||s>n)return{error:`--offset must be an integer in [0, ${n}] (got "${e}")`};i=s}return{limit:o,offset:i}}function C(t,e){if(!e)return t;let r=e.toLowerCase();return t.filter(n=>n.name.toLowerCase().includes(r))}function j(t,{limit:e,offset:r}){let n=t.slice(r,r+e),o=t.length>r+e;return{slice:n,hasMore:o}}function v(t,e,r=n=>process.stdout.write(`${n}
2
+ import{a as k}from"./chunk-CRPBARFG.js";import{a as m}from"./chunk-BPMSNGXQ.js";import{r as a}from"./chunk-RSSOJ3L2.js";import{a as y}from"./chunk-BE4FBVKY.js";import{a as h}from"./chunk-NVRXDLJN.js";var $=10,u=200,N=1e4,S=1e6;function T(t,e,r="streaming"){let n=r==="full-fetch"?S:N,o=$,i=0;if(t!==void 0){let s=Number(t);if(!Number.isInteger(s)||s<1||s>u)return{error:`--limit must be an integer in [1, ${u}] (got "${t}")`};o=s}if(e!==void 0){let s=Number(e);if(!Number.isInteger(s)||s<0||s>n)return{error:`--offset must be an integer in [0, ${n}] (got "${e}")`};i=s}return{limit:o,offset:i}}function C(t,e){if(!e)return t;let r=e.toLowerCase();return t.filter(n=>n.name.toLowerCase().includes(r))}function j(t,{limit:e,offset:r}){let n=t.slice(r,r+e),o=t.length>r+e;return{slice:n,hasMore:o}}function v(t,e,r=n=>process.stdout.write(`${n}
3
3
  `)){for(let n of t)r(JSON.stringify(n));r(JSON.stringify({_meta:"page",limit:e.limit,offset:e.offset,returned:t.length,has_more:e.has_more}))}function b(t,e,r=n=>process.stdout.write(`${n}
4
- `)){if(t.length===0){r("(no results)");return}let n=Math.max(2,...t.map(s=>s.id.length)),o=`${"ID".padEnd(n)} NAME`;r(o),r(`${"-".repeat(n)} ----`);for(let s of t)r(`${s.id.padEnd(n)} ${s.name}`);r("");let i=e.offset+t.length;if(e.hasMore){let s=e.totalIsLowerBound?`${e.total}+`:`${e.total}`;r(`${i} of ${s} \u2014 next: --offset ${e.offset+e.limit}`)}else r(`${t.length} shown (${e.total} total)`)}async function B(t,e,r){if(r.username&&r.accessKey)return{ok:!0,creds:{username:r.username,access_key:r.accessKey}};let n=new h,o=n.loadBasicAuth(t,e);if(o)return{ok:!0,creds:{username:o.username,access_key:o.access_key}};let i=n.loadCredentials(t,e);if(!i)return{ok:!1,reason:"no_credentials"};let s=i.access_token;try{let{refreshOAuthToken:d}=await import("./token-refresh-ZFT457VI.js"),w=await d({creds:n,profile:t,env:e,credentials:i});w&&(s=w.accessToken)}catch(d){return{ok:!1,reason:"refresh_failed",detail:d instanceof Error?d.message:String(d)}}let c=y(e),f=await new k(c.controllerBaseUrl,async()=>s,null).resolve();return f?{ok:!0,creds:{username:f.username,access_key:f.access_key}}:{ok:!1,reason:"exchange_failed"}}function E(t,e,r){switch(r.reason){case"no_credentials":return{message:`error: no credentials for profile "${t}" [${e}]. Run \`kane-cli login\` or pass --username/--access-key.
4
+ `)){if(t.length===0){r("(no results)");return}let n=Math.max(2,...t.map(s=>s.id.length)),o=`${"ID".padEnd(n)} NAME`;r(o),r(`${"-".repeat(n)} ----`);for(let s of t)r(`${s.id.padEnd(n)} ${s.name}`);r("");let i=e.offset+t.length;if(e.hasMore){let s=e.totalIsLowerBound?`${e.total}+`:`${e.total}`;r(`${i} of ${s} \u2014 next: --offset ${e.offset+e.limit}`)}else r(`${t.length} shown (${e.total} total)`)}async function B(t,e,r){if(r.username&&r.accessKey)return{ok:!0,creds:{username:r.username,access_key:r.accessKey}};let n=new h,o=n.loadBasicAuth(t,e);if(o)return{ok:!0,creds:{username:o.username,access_key:o.access_key}};let i=n.loadCredentials(t,e);if(!i)return{ok:!1,reason:"no_credentials"};let s=i.access_token;try{let{refreshOAuthToken:d}=await import("./token-refresh-IT4LVE2H.js"),w=await d({creds:n,profile:t,env:e,credentials:i});w&&(s=w.accessToken)}catch(d){return{ok:!1,reason:"refresh_failed",detail:d instanceof Error?d.message:String(d)}}let c=y(e),f=await new k(c.controllerBaseUrl,async()=>s,null).resolve();return f?{ok:!0,creds:{username:f.username,access_key:f.access_key}}:{ok:!1,reason:"exchange_failed"}}function E(t,e,r){switch(r.reason){case"no_credentials":return{message:`error: no credentials for profile "${t}" [${e}]. Run \`kane-cli login\` or pass --username/--access-key.
5
5
  `,exitCode:2};case"refresh_failed":return{message:`error: OAuth token refresh failed for profile "${t}" [${e}]${r.detail?`: ${r.detail}`:""}. Run \`kane-cli login\` to re-auth.
6
6
  `,exitCode:2};case"exchange_failed":return{message:`error: TMS credential exchange failed for profile "${t}" [${e}]. Token may be revoked \u2014 try \`kane-cli login\`; if the problem persists, TMS may be down.
7
7
  `,exitCode:2}}}function O(t){return{id:t.project_id,name:t.name}}function M(t){return{id:t.id,name:t.name}}async function P(t,e,r,n){let o=r+n+1,i=[],s=!0;for await(let c of t.listProjectsStream({name:e})){if(i.push(...c.projects),c.done){s=!0;break}if(i.length>=o){s=!1;break}}return{items:i,doneStreaming:s}}function g(t){return!!t.agent||!process.stdin.isTTY||!process.stdout.isTTY}function _(t,e=r=>process.stdout.write(`${r}
@@ -1,3 +1,3 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
2
  function l(r){let{isAgent:m,log:d}=r,a=r.stdout??process.stderr,s=r.stdin??process.stdin,p=t=>{m&&process.stdout.write(JSON.stringify(t)+`
3
- `)};return{async runSteps(t){let{default:e}=await import("./react-QWOAB3TB.js"),{render:o}=await import("./build-JIKYOZUH.js"),{TestMdRunView:i}=await import("./TestMdRunView-KLMMXQCN.js"),{ScrollbackProvider:n}=await import("./scrollback-JLPJR25X.js"),{waitUntilExit:c}=o(e.createElement(n,null,e.createElement(i,t)),{stdout:a,stdin:s,exitOnCtrlC:!1});await c()},async runUpload(t,e){let{renderUploadProgress:o}=await import("./CliUploadProgress-TMVTKNOT.js");return await o(t,e)},async onSummary(t){try{let{default:e}=await import("./react-QWOAB3TB.js"),{render:o}=await import("./build-JIKYOZUH.js"),{AutoExitSummaryBox:i}=await import("./SummaryBox-GKHU4C4H.js"),{waitUntilExit:n}=o(e.createElement(i,{data:t}),{stdout:a,stdin:s});await n()}catch(e){d("warn","TEST_MD_SUMMARY_RENDER_FAILED","Summary box render failed",{error:String(e)})}},async onLinks(t){try{let{default:e}=await import("./react-QWOAB3TB.js"),{render:o}=await import("./build-JIKYOZUH.js"),{LinksBox:i}=await import("./LinksBox-5XNJ3UJJ.js"),{waitUntilExit:n}=o(e.createElement(i,t),{stdout:a,stdin:s});await n()}catch(e){d("warn","TEST_MD_LINKS_RENDER_FAILED","LinksBox render failed",{error:String(e)})}},onLockState(t){p({type:"test_md_lock_state",...t})},onAdaptiveHeal(t){p({type:"test_md_adaptive_heal",...t})},onAgentEvent(t){p(t)}}}export{l as a};
3
+ `)};return{async runSteps(t){let{default:e}=await import("./react-QWOAB3TB.js"),{render:o}=await import("./build-JIKYOZUH.js"),{TestMdRunView:i}=await import("./TestMdRunView-6X6W5YAP.js"),{ScrollbackProvider:n}=await import("./scrollback-JLPJR25X.js"),{waitUntilExit:c}=o(e.createElement(n,null,e.createElement(i,t)),{stdout:a,stdin:s,exitOnCtrlC:!1});await c()},async runUpload(t,e){let{renderUploadProgress:o}=await import("./CliUploadProgress-53LQMQJD.js");return await o(t,e)},async onSummary(t){try{let{default:e}=await import("./react-QWOAB3TB.js"),{render:o}=await import("./build-JIKYOZUH.js"),{AutoExitSummaryBox:i}=await import("./SummaryBox-A6LKKQXJ.js"),{waitUntilExit:n}=o(e.createElement(i,{data:t}),{stdout:a,stdin:s});await n()}catch(e){d("warn","TEST_MD_SUMMARY_RENDER_FAILED","Summary box render failed",{error:String(e)})}},async onLinks(t){try{let{default:e}=await import("./react-QWOAB3TB.js"),{render:o}=await import("./build-JIKYOZUH.js"),{LinksBox:i}=await import("./LinksBox-6NS3GHWO.js"),{waitUntilExit:n}=o(e.createElement(i,t),{stdout:a,stdin:s});await n()}catch(e){d("warn","TEST_MD_LINKS_RENDER_FAILED","LinksBox render failed",{error:String(e)})}},onLockState(t){p({type:"test_md_lock_state",...t})},onAdaptiveHeal(t){p({type:"test_md_adaptive_heal",...t})},onAgentEvent(t){p(t)}}}export{l as a};
@@ -1,3 +1,3 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{d as X}from"./chunk-BB2W35TW.js";import{a as $}from"./chunk-YKTYVJBN.js";import{C as T,n as z,o as Y,p as H}from"./chunk-W3Z7AZNT.js";import{b as q,h as N}from"./chunk-XMTSHHYQ.js";import{a as W,d as S,f as L}from"./chunk-DBIBROYW.js";import{c as C}from"./chunk-UD7KKHPW.js";import{a as K,b as J}from"./chunk-DWHXXPDX.js";var ce=3,de=1e4,Q=()=>new Promise(r=>setTimeout(r,25+Math.floor(Math.random()*50))),Z=r=>r==="design"||r==="maintain"?"session":r==="revert"||r==="shape-op"?"exclusive":"commit";function le(r,e,o){for(let s of r){for(let t of s.supersessions)if(t.kind==="node"&&(o.has(t.old)||t.new!==null&&o.has(t.new)))return!0;for(let t of s.nodes)if(t.label==="usecase"&&e.newBuCandidates.length>0||o.has(t.cid))return!0;if(s.design_generation&&e.generationTicket&&s.design_generation.uc_root===e.generationTicket.uc_root)return!0;for(let t of e.sourcePins)if(Object.prototype.hasOwnProperty.call(s.source_head_moves,t.source_id))return!0}return!1}async function De(r,e,o){let{contextDir:s,locks:t,probe:a}=r,m=r.sid??r.rootSid,f=e.newBuCandidates.map(b=>({tempRef:b.tempRef,probeText:b.probeText})),k=0,g=!0,p={hits:[],degraded:!1,probeBasis:null};for(;;){g&&(f.length>0&&(p=await a.batchSimilar(T(s),f)),g=!1);let b=T(s),_={seq:b.lastSeq,hash:b.latestHash},P=new Map,w=[],v=[],R=new Set;for(let d of e.ucTargets){let c=H(b,d.ref);if(c===null)return{ok:!1,kind:"validation",errors:[{code:"UNKNOWN_REF",detail:`${d.ref}: names no living node (unknown or tombstoned chain)`}]};d.expectedTip!==void 0&&d.expectedTip!==c.cid&&P.set(d.expectedTip,c.cid),R.add(c.cid),v.push(L(b,d.ref).key)}(e.verb==="revert"||e.verb==="shape-op")&&(v.length=0,v.push({kind:"context",mode:"exclusive"}));let y;try{y=t.acquire(S(v),{hold:Z(e.verb),verb:e.verb})}catch(d){if(d instanceof W&&(d.code==="UC_HELD"||d.code==="CONTEXT_HELD"))return{ok:!1,kind:"contended",err:d};throw d}let V=!1,M=!1;try{let d=await t.withKeySerialized(v,async()=>{let c=T(s),O=_.hash===c.latestHash?[]:N(s,_.seq,_.hash).records;for(let n of e.ucTargets){let i=H(c,n.ref);if(i===null){w.push({kind:"supersession",ref:n.ref,detail:`${n.ref} was retired while this commit staged \u2014 re-ground or abandon`});continue}for(let l of R)c.superseded.has(l)&&c.tipOf(l)===i.cid&&P.set(l,i.cid)}for(let n of e.sourcePins){let i=c.heads.get(n.source_id);i!=null&&i!==n.source_cid&&w.push({kind:"pin",ref:n.source_id,detail:`source '${n.source_id}' moved (pinned ${n.source_cid.slice(0,19)}, head ${i.slice(0,19)}) \u2014 re-ground or abandon`})}if(w.length>0)return{ok:!1,kind:"drifted",asks:w};if(e.generationTicket){let n=X(c,e.generationTicket);if(n!==null)return{ok:!1,kind:"validation",errors:[n]}}if(f.length>0&&O.length>0){let n=new Set(p.hits.map(u=>u.candidateCid)),i=a.recheckLocal(c,f,p.probeBasis,O);if(i.hits.some(u=>!n.has(u.candidateCid))||i.uncachedNewNodes.length>0)return M=!0,"restart"}if(e.verb!=="revert"&&e.verb!=="shape-op"){let n=S(e.ucTargets.map(u=>L(c,u.ref).key)),i=S(v);if(!(n.length===i.length&&n.every((u,h)=>JSON.stringify(u)===JSON.stringify(i[h]))))return"restart"}if(e.eventIds&&e.eventIds.length>0&&e.eventIds.every(n=>c.appliedEvents.has(n)))return{ok:!0,skipped:"already-applied"};let ae=Date.now()+de,j=c.latestHash,E=c;for(;;){let n={graph:E,expectPrev:j,redirects:P,probeHits:p.hits,degradedProbe:p.degraded,sid:m,eventIds:(l,u)=>{if(e.eventIds&&e.eventIds.length>0)return e.eventIds.slice(0,u);let h=Y(E,r.rootSid,l,u),U=r.reservedEventIds??[];if(U.length===0)return h;let D=`${r.rootSid}:${l}:`,A=0;for(let F of U){if(!F.startsWith(D))continue;let x=F.slice(D.length);/^\d+$/.test(x)&&(A=Math.max(A,Number.parseInt(x,10)))}if(A===0)return h;let G=Number.parseInt(h[0].slice(D.length),10);return!Number.isInteger(G)||G>A?h:Array.from({length:u},(F,x)=>z(r.rootSid,l,A+1+x))},assertLocks:()=>y.assertHeld()};if(r.revalidate){let l=r.revalidate(n);if(l.length>0)return{ok:!1,kind:"validation",errors:l}}y.assertHeld();let i;try{i=o(n)}catch(l){if(l instanceof q){let u=T(s),h=N(s,E.lastSeq,E.latestHash).records;if(!le(h,e,R)&&Date.now()<ae){await Q(),E=u,j=u.latestHash;continue}return"restart"}throw l}return"errors"in i?{ok:!1,kind:"validation",errors:i.errors}:(Z(e.verb)==="session"&&y.touch(),{ok:!0,result:i.result,record:i.record})}});if(d==="restart")V=!0;else return d}finally{y.release()}if(V){if(k+=1,k>=ce)return{ok:!1,kind:"unsettled",attempts:k};M&&(g=!0),await Q();continue}}}import{readFileSync as ue,writeFileSync as fe,renameSync as me,mkdirSync as pe}from"fs";import{dirname as he,join as ge}from"path";var B=1,be=720*60*1e3;function I(r){return ge(J,"embeddings",`alias-${r}.json`)}function ee(r,e=Date.now()){return r!==null&&e-r.fetchedAt<be}function re(r){try{let e=JSON.parse(ue(r,"utf-8"));return e.wrapperVersion!==B||typeof e.purposes!="object"||e.purposes===null?null:{wrapperVersion:B,writtenByVersion:String(e.writtenByVersion??""),purposes:e.purposes}}catch{return null}}function te(r,e,o=I(r)){let t=re(o)?.purposes?.[e];return!t||typeof t.alias!="string"||typeof t.dims!="number"||typeof t.fetchedAt!="number"?null:{alias:t.alias,dims:t.dims,fetchedAt:t.fetchedAt}}function se(r,e,o,s=I(r)){try{pe(he(s),{recursive:!0});let a=re(s)?.purposes??{};a[e]={alias:o.alias,dims:o.dims,fetchedAt:Date.now()};let m={wrapperVersion:B,writtenByVersion:K,purposes:a},f=`${s}.tmp`;fe(f,JSON.stringify(m,null,2)+`
2
+ import{d as X}from"./chunk-BB2W35TW.js";import{a as $}from"./chunk-YKTYVJBN.js";import{C as T,n as z,o as Y,p as H}from"./chunk-R4EGL7VM.js";import{b as q,h as N}from"./chunk-OXHMUZJV.js";import{a as W,d as S,f as L}from"./chunk-DBIBROYW.js";import{c as C}from"./chunk-UD7KKHPW.js";import{a as K,b as J}from"./chunk-DEUDRSU7.js";var ce=3,de=1e4,Q=()=>new Promise(r=>setTimeout(r,25+Math.floor(Math.random()*50))),Z=r=>r==="design"||r==="maintain"?"session":r==="revert"||r==="shape-op"?"exclusive":"commit";function le(r,e,o){for(let s of r){for(let t of s.supersessions)if(t.kind==="node"&&(o.has(t.old)||t.new!==null&&o.has(t.new)))return!0;for(let t of s.nodes)if(t.label==="usecase"&&e.newBuCandidates.length>0||o.has(t.cid))return!0;if(s.design_generation&&e.generationTicket&&s.design_generation.uc_root===e.generationTicket.uc_root)return!0;for(let t of e.sourcePins)if(Object.prototype.hasOwnProperty.call(s.source_head_moves,t.source_id))return!0}return!1}async function De(r,e,o){let{contextDir:s,locks:t,probe:a}=r,m=r.sid??r.rootSid,f=e.newBuCandidates.map(b=>({tempRef:b.tempRef,probeText:b.probeText})),k=0,g=!0,p={hits:[],degraded:!1,probeBasis:null};for(;;){g&&(f.length>0&&(p=await a.batchSimilar(T(s),f)),g=!1);let b=T(s),_={seq:b.lastSeq,hash:b.latestHash},P=new Map,w=[],v=[],R=new Set;for(let d of e.ucTargets){let c=H(b,d.ref);if(c===null)return{ok:!1,kind:"validation",errors:[{code:"UNKNOWN_REF",detail:`${d.ref}: names no living node (unknown or tombstoned chain)`}]};d.expectedTip!==void 0&&d.expectedTip!==c.cid&&P.set(d.expectedTip,c.cid),R.add(c.cid),v.push(L(b,d.ref).key)}(e.verb==="revert"||e.verb==="shape-op")&&(v.length=0,v.push({kind:"context",mode:"exclusive"}));let y;try{y=t.acquire(S(v),{hold:Z(e.verb),verb:e.verb})}catch(d){if(d instanceof W&&(d.code==="UC_HELD"||d.code==="CONTEXT_HELD"))return{ok:!1,kind:"contended",err:d};throw d}let V=!1,M=!1;try{let d=await t.withKeySerialized(v,async()=>{let c=T(s),O=_.hash===c.latestHash?[]:N(s,_.seq,_.hash).records;for(let n of e.ucTargets){let i=H(c,n.ref);if(i===null){w.push({kind:"supersession",ref:n.ref,detail:`${n.ref} was retired while this commit staged \u2014 re-ground or abandon`});continue}for(let l of R)c.superseded.has(l)&&c.tipOf(l)===i.cid&&P.set(l,i.cid)}for(let n of e.sourcePins){let i=c.heads.get(n.source_id);i!=null&&i!==n.source_cid&&w.push({kind:"pin",ref:n.source_id,detail:`source '${n.source_id}' moved (pinned ${n.source_cid.slice(0,19)}, head ${i.slice(0,19)}) \u2014 re-ground or abandon`})}if(w.length>0)return{ok:!1,kind:"drifted",asks:w};if(e.generationTicket){let n=X(c,e.generationTicket);if(n!==null)return{ok:!1,kind:"validation",errors:[n]}}if(f.length>0&&O.length>0){let n=new Set(p.hits.map(u=>u.candidateCid)),i=a.recheckLocal(c,f,p.probeBasis,O);if(i.hits.some(u=>!n.has(u.candidateCid))||i.uncachedNewNodes.length>0)return M=!0,"restart"}if(e.verb!=="revert"&&e.verb!=="shape-op"){let n=S(e.ucTargets.map(u=>L(c,u.ref).key)),i=S(v);if(!(n.length===i.length&&n.every((u,h)=>JSON.stringify(u)===JSON.stringify(i[h]))))return"restart"}if(e.eventIds&&e.eventIds.length>0&&e.eventIds.every(n=>c.appliedEvents.has(n)))return{ok:!0,skipped:"already-applied"};let ae=Date.now()+de,j=c.latestHash,E=c;for(;;){let n={graph:E,expectPrev:j,redirects:P,probeHits:p.hits,degradedProbe:p.degraded,sid:m,eventIds:(l,u)=>{if(e.eventIds&&e.eventIds.length>0)return e.eventIds.slice(0,u);let h=Y(E,r.rootSid,l,u),U=r.reservedEventIds??[];if(U.length===0)return h;let D=`${r.rootSid}:${l}:`,A=0;for(let F of U){if(!F.startsWith(D))continue;let x=F.slice(D.length);/^\d+$/.test(x)&&(A=Math.max(A,Number.parseInt(x,10)))}if(A===0)return h;let G=Number.parseInt(h[0].slice(D.length),10);return!Number.isInteger(G)||G>A?h:Array.from({length:u},(F,x)=>z(r.rootSid,l,A+1+x))},assertLocks:()=>y.assertHeld()};if(r.revalidate){let l=r.revalidate(n);if(l.length>0)return{ok:!1,kind:"validation",errors:l}}y.assertHeld();let i;try{i=o(n)}catch(l){if(l instanceof q){let u=T(s),h=N(s,E.lastSeq,E.latestHash).records;if(!le(h,e,R)&&Date.now()<ae){await Q(),E=u,j=u.latestHash;continue}return"restart"}throw l}return"errors"in i?{ok:!1,kind:"validation",errors:i.errors}:(Z(e.verb)==="session"&&y.touch(),{ok:!0,result:i.result,record:i.record})}});if(d==="restart")V=!0;else return d}finally{y.release()}if(V){if(k+=1,k>=ce)return{ok:!1,kind:"unsettled",attempts:k};M&&(g=!0),await Q();continue}}}import{readFileSync as ue,writeFileSync as fe,renameSync as me,mkdirSync as pe}from"fs";import{dirname as he,join as ge}from"path";var B=1,be=720*60*1e3;function I(r){return ge(J,"embeddings",`alias-${r}.json`)}function ee(r,e=Date.now()){return r!==null&&e-r.fetchedAt<be}function re(r){try{let e=JSON.parse(ue(r,"utf-8"));return e.wrapperVersion!==B||typeof e.purposes!="object"||e.purposes===null?null:{wrapperVersion:B,writtenByVersion:String(e.writtenByVersion??""),purposes:e.purposes}}catch{return null}}function te(r,e,o=I(r)){let t=re(o)?.purposes?.[e];return!t||typeof t.alias!="string"||typeof t.dims!="number"||typeof t.fetchedAt!="number"?null:{alias:t.alias,dims:t.dims,fetchedAt:t.fetchedAt}}function se(r,e,o,s=I(r)){try{pe(he(s),{recursive:!0});let a=re(s)?.purposes??{};a[e]={alias:o.alias,dims:o.dims,fetchedAt:Date.now()};let m={wrapperVersion:B,writtenByVersion:K,purposes:a},f=`${s}.tmp`;fe(f,JSON.stringify(m,null,2)+`
3
3
  `),me(f,s)}catch(t){C(`[embed] Failed to save alias cache: ${t instanceof Error?t.message:String(t)}`,"EMBED_CACHE_WRITE_FAILED")}}function ve(r){return r.TESTMUAI_ENV==="stage"?"stage":"prod"}function oe(r){let e=r.env??process.env,o=r.auth?.TESTMUAI_BASIC_AUTH||e.TESTMUAI_BASIC_AUTH;if(o)return{authorization:`Basic ${o}`};let s=r.auth?.TESTMUAI_API_KEY||e.TESTMUAI_API_KEY;return s?{authorization:`Bearer ${s}`}:{}}async function Oe(r,e={}){let o=e.env??process.env,s=ve(o),t=e.aliasCacheFile??I(s),a=e.now??Date.now,m=te(s,r,t);if(ee(m,a()))return{alias:m.alias,dims:m.dims};let k=`${$(o)}/assurance/embed/alias?purpose=${encodeURIComponent(r)}`,g=await(e.fetchImpl??fetch)(k,{method:"GET",headers:oe(e)});if(!g.ok)throw new Error(`embed alias resolve failed: ${g.status}`);let p=await g.json();return se(s,r,{alias:p.alias,dims:p.dims},t),{alias:p.alias,dims:p.dims}}async function je(r,e,o={}){let s=o.env??process.env,t=$(s),a=await(o.fetchImpl??fetch)(`${t}/assurance/embed`,{method:"POST",headers:{...oe(o),"content-type":"application/json"},body:JSON.stringify({purpose:r,input:e})});if(!a.ok)throw new Error(`embed failed: ${a.status}`);return await a.json()}import{readFileSync as ke,writeFileSync as ye,renameSync as Ee,mkdirSync as Ae}from"fs";import{dirname as Te,join as ne}from"path";function we(r){return ne(r,"embeddings")}function xe(r){let e=r.indexOf(":");return e>=0?r.slice(e+1):r}function ie(r,e,o){let s=xe(o);return ne(we(r),e,s.slice(0,2),`${s.slice(2)}.f32`)}function We(r,e,o){try{let s=ke(ie(r,e,o)),t=new Float32Array(Math.floor(s.length/4));for(let a=0;a<t.length;a++)t[a]=s.readFloatLE(a*4);return t}catch{return null}}function qe(r,e,o,s){try{let t=ie(r,e,o);Ae(Te(t),{recursive:!0});let a=Buffer.alloc(s.length*4);for(let f=0;f<s.length;f++)a.writeFloatLE(s[f],f*4);let m=`${t}.tmp`;ye(m,a),Ee(m,t)}catch(t){C(`[embed] Failed to cache vector: ${t instanceof Error?t.message:String(t)}`,"EMBED_CACHE_WRITE_FAILED")}}export{De as a,Oe as b,je as c,We as d,qe as e};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as V,e as I,i as L}from"./chunk-XMTSHHYQ.js";var N="ckpt/1";var H="checkpoints",P="base.json",y=t=>`delta-${t}.json`,w=t=>`full-${t}.json`,oe=["turn","ask","final"],ae=["extract","design","walk"];function _(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function x(t){return Array.isArray(t)&&t.every(n=>typeof n=="string")}function B(t){let n=[],e=(s,a)=>{s||n.push(a)};if(!_(t))return{ok:!1,errors:["record: not an object"]};e(t.schema===N,`schema: expected "${N}"`);let r=t.kind;if(r==="base")e(typeof t.sid=="string"&&t.sid.length>0,"base.sid: non-empty string"),e(typeof t.verb=="string"&&ae.includes(t.verb),"base.verb: extract|design|walk"),e(typeof t.mode=="string","base.mode: string"),e(typeof t.created_at=="string","base.created_at: string"),e(_(t.run_config),"base.run_config: object"),_(t.run_config)&&e(!("resume"in t.run_config),"base.run_config: must not carry `resume`"),e(typeof t.conv_source=="string",'base.conv_source: string ("" when absent)'),e(typeof t.store_watermark=="string"||t.store_watermark===null,"base.store_watermark: string | null (null = genesis)");else if(r==="delta"||r==="full"){e(typeof t.sid=="string"&&t.sid.length>0,"delta.sid: non-empty string"),e(Number.isInteger(t.seq)&&t.seq>=1,"delta.seq: integer \u2265 1"),e(Number.isInteger(t.turn_id),"delta.turn_id: integer"),e(typeof t.at=="string"&&oe.includes(t.at),"delta.at: turn|ask|final"),e(typeof t.ts=="string","delta.ts: string");let s=t.agent;if(_(s)){e(Number.isInteger(s.agent_state_schema),"agent.agent_state_schema: integer"),e(Array.isArray(s.delta_items),"agent.delta_items: array"),e(_(s.binding),"agent.binding: object");let o=s.usage_total;e(_(o)&&typeof o.input_tokens=="number"&&typeof o.output_tokens=="number"&&typeof o.credits=="number","agent.usage_total: {input_tokens, output_tokens, credits} numbers"),s.base_fingerprint!==void 0&&e(typeof s.base_fingerprint=="string","agent.base_fingerprint: string when present"),r==="full"&&e(typeof s.base_fingerprint=="string","full: agent.base_fingerprint required")}else n.push("delta.agent: object");let a=t.kane;if(_(a)){e(x(a.applied_events),"kane.applied_events: string[]"),e(x(a.held_receipts),"kane.held_receipts: string[]");let o=a.pending;e(_(o)&&Array.isArray(o.questions)&&Array.isArray(o.proposals),"kane.pending: {questions[], proposals[]}"),e(Array.isArray(a.parent_asks),"kane.parent_asks: array"),e(_(a.read_basis),"kane.read_basis: object");let p=a.corpus_cursor;e(_(p)&&x(p.remaining),"kane.corpus_cursor: {remaining: string[]}"),e(typeof a.store_watermark=="string"||a.store_watermark===null,"kane.store_watermark: string | null (null = genesis)"),a.ingest_registry!==void 0&&e(Array.isArray(a.ingest_registry)&&a.ingest_registry.every(i=>_(i)&&typeof i.ref=="string"&&typeof i.entered_at=="string"),"kane.ingest_registry: [{ref, entered_at, consumed?}]"),a.ingest_schedule!==void 0&&e(Array.isArray(a.ingest_schedule)&&a.ingest_schedule.every(i=>_(i)&&typeof i.source_id=="string"&&typeof i.cid=="string"&&["pending","done","skipped"].includes(String(i.status))),"kane.ingest_schedule: [{source_id, cid, status}]")}else n.push("delta.kane: object")}else n.push('kind: expected "base" | "delta" | "full"');return{ok:n.length===0,errors:n}}import{closeSync as U,existsSync as Z,fsyncSync as Y,mkdirSync as ee,openSync as W,readFileSync as te,readdirSync as ne,renameSync as ce,rmSync as K,statSync as pe,writeFileSync as de}from"fs";import{join as m}from"path";var ue=3,we=600*1e3,A=class extends Error{constructor(e,r){super(`${e}: ${r}`);this.code=e}},S=class extends Error{constructor(n){super(`CHECKPOINT_WRITE: ${n}`)}},j=class extends S{},E=(t,n)=>m(t,"sessions",n,H),le=(t,n)=>m(t,"sessions",n,"state.json");function F(t,n,e){let r=`${t}.tmp-${process.pid}`,s=W(r,"w");try{de(s,n,{mode:384}),Y(s)}finally{U(s)}ce(r,t);try{let a=W(e,"r");Y(a),U(a)}catch{}}var ge=new Set,J=new Set;function G(t){let n=0;try{for(let e of ne(t))try{n+=pe(m(t,e)).size}catch{}}catch{return 0}return n}function z(t,n,e){for(let r of ge)try{r(t,n,e)}catch{}}var fe=new Set;function Se(t,n=new Date){for(let e of fe)try{e(t,n)}catch{}}function Ae(t,n,e){let r=E(t,n);ee(r,{recursive:!0});let s=m(r,P);Z(s)||F(s,JSON.stringify(e)+`
2
+ import{a as V,e as I,i as L}from"./chunk-OXHMUZJV.js";var N="ckpt/1";var H="checkpoints",P="base.json",y=t=>`delta-${t}.json`,w=t=>`full-${t}.json`,oe=["turn","ask","final"],ae=["extract","design","walk"];function _(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function x(t){return Array.isArray(t)&&t.every(n=>typeof n=="string")}function B(t){let n=[],e=(s,a)=>{s||n.push(a)};if(!_(t))return{ok:!1,errors:["record: not an object"]};e(t.schema===N,`schema: expected "${N}"`);let r=t.kind;if(r==="base")e(typeof t.sid=="string"&&t.sid.length>0,"base.sid: non-empty string"),e(typeof t.verb=="string"&&ae.includes(t.verb),"base.verb: extract|design|walk"),e(typeof t.mode=="string","base.mode: string"),e(typeof t.created_at=="string","base.created_at: string"),e(_(t.run_config),"base.run_config: object"),_(t.run_config)&&e(!("resume"in t.run_config),"base.run_config: must not carry `resume`"),e(typeof t.conv_source=="string",'base.conv_source: string ("" when absent)'),e(typeof t.store_watermark=="string"||t.store_watermark===null,"base.store_watermark: string | null (null = genesis)");else if(r==="delta"||r==="full"){e(typeof t.sid=="string"&&t.sid.length>0,"delta.sid: non-empty string"),e(Number.isInteger(t.seq)&&t.seq>=1,"delta.seq: integer \u2265 1"),e(Number.isInteger(t.turn_id),"delta.turn_id: integer"),e(typeof t.at=="string"&&oe.includes(t.at),"delta.at: turn|ask|final"),e(typeof t.ts=="string","delta.ts: string");let s=t.agent;if(_(s)){e(Number.isInteger(s.agent_state_schema),"agent.agent_state_schema: integer"),e(Array.isArray(s.delta_items),"agent.delta_items: array"),e(_(s.binding),"agent.binding: object");let o=s.usage_total;e(_(o)&&typeof o.input_tokens=="number"&&typeof o.output_tokens=="number"&&typeof o.credits=="number","agent.usage_total: {input_tokens, output_tokens, credits} numbers"),s.base_fingerprint!==void 0&&e(typeof s.base_fingerprint=="string","agent.base_fingerprint: string when present"),r==="full"&&e(typeof s.base_fingerprint=="string","full: agent.base_fingerprint required")}else n.push("delta.agent: object");let a=t.kane;if(_(a)){e(x(a.applied_events),"kane.applied_events: string[]"),e(x(a.held_receipts),"kane.held_receipts: string[]");let o=a.pending;e(_(o)&&Array.isArray(o.questions)&&Array.isArray(o.proposals),"kane.pending: {questions[], proposals[]}"),e(Array.isArray(a.parent_asks),"kane.parent_asks: array"),e(_(a.read_basis),"kane.read_basis: object");let p=a.corpus_cursor;e(_(p)&&x(p.remaining),"kane.corpus_cursor: {remaining: string[]}"),e(typeof a.store_watermark=="string"||a.store_watermark===null,"kane.store_watermark: string | null (null = genesis)"),a.ingest_registry!==void 0&&e(Array.isArray(a.ingest_registry)&&a.ingest_registry.every(i=>_(i)&&typeof i.ref=="string"&&typeof i.entered_at=="string"),"kane.ingest_registry: [{ref, entered_at, consumed?}]"),a.ingest_schedule!==void 0&&e(Array.isArray(a.ingest_schedule)&&a.ingest_schedule.every(i=>_(i)&&typeof i.source_id=="string"&&typeof i.cid=="string"&&["pending","done","skipped"].includes(String(i.status))),"kane.ingest_schedule: [{source_id, cid, status}]")}else n.push("delta.kane: object")}else n.push('kind: expected "base" | "delta" | "full"');return{ok:n.length===0,errors:n}}import{closeSync as U,existsSync as Z,fsyncSync as Y,mkdirSync as ee,openSync as W,readFileSync as te,readdirSync as ne,renameSync as ce,rmSync as K,statSync as pe,writeFileSync as de}from"fs";import{join as m}from"path";var ue=3,we=600*1e3,A=class extends Error{constructor(e,r){super(`${e}: ${r}`);this.code=e}},S=class extends Error{constructor(n){super(`CHECKPOINT_WRITE: ${n}`)}},j=class extends S{},E=(t,n)=>m(t,"sessions",n,H),le=(t,n)=>m(t,"sessions",n,"state.json");function F(t,n,e){let r=`${t}.tmp-${process.pid}`,s=W(r,"w");try{de(s,n,{mode:384}),Y(s)}finally{U(s)}ce(r,t);try{let a=W(e,"r");Y(a),U(a)}catch{}}var ge=new Set,J=new Set;function G(t){let n=0;try{for(let e of ne(t))try{n+=pe(m(t,e)).size}catch{}}catch{return 0}return n}function z(t,n,e){for(let r of ge)try{r(t,n,e)}catch{}}var fe=new Set;function Se(t,n=new Date){for(let e of fe)try{e(t,n)}catch{}}function Ae(t,n,e){let r=E(t,n);ee(r,{recursive:!0});let s=m(r,P);Z(s)||F(s,JSON.stringify(e)+`
3
3
  `,r)}function _e(t,n){let e;try{e=JSON.parse(n)}catch(s){throw new A("CHECKPOINT_CORRUPT",`${t}: ${s.message}`)}let r=B(e);if(!r.ok)throw new A("CHECKPOINT_CORRUPT",`${t}: ${r.errors.join("; ")}`);return e}function M(t,n,e){let r=m(E(t,n),e);return _e(e,te(r,"utf8"))}function re(t,n){let e=[],r=[],s=[];try{s=ne(E(t,n))}catch{return{deltas:e,fulls:r}}for(let a of s){let o=/^delta-(\d+)\.json$/.exec(a);o&&e.push(Number(o[1]));let p=/^full-(\d+)\.json$/.exec(a);p&&r.push(Number(p[1]))}return e.sort((a,o)=>a-o),r.sort((a,o)=>a-o),{deltas:e,fulls:r}}function me(t,n){try{return JSON.parse(te(le(t,n),"utf8")).checkpoint??null}catch{return null}}function se(t,n,e){let r=[],s,a=0;if(e.full_seq!==null){let i=M(t,n,w(e.full_seq));r.push(i),s=i.agent.base_fingerprint,a=e.full_seq}let o;for(let i=a+1;i<=e.seq;i++)try{let d=M(t,n,y(i));r.push(d),!s&&d.agent.base_fingerprint&&(s=d.agent.base_fingerprint)}catch(d){if(d instanceof A&&d.code==="CHECKPOINT_CORRUPT"){o={resumableAt:i-1,turnsLost:e.seq-(i-1)};break}throw d}if(r.length===0)throw new A("CHECKPOINT_CORRUPT",`${n}: pointer names seq ${e.seq} but no chain records exist`);return{items:r.flatMap(i=>i.agent.delta_items),last:r[r.length-1],base_fingerprint:s,fallback:o}}function Re(t,n,e,r,s){let a=performance.now(),o=n.state.sid,p=n.state.checkpoint;if(p){if(e.seq<p.seq)throw new S(`seq regression: got ${e.seq}, pointer at ${p.seq} (${o})`);if(e.seq===p.seq){if(e.turn_id===p.turn_id&&e.at===p.at)return p;throw new S(`seq regression: seq ${e.seq} re-used with different metadata (turn ${e.turn_id}/${p.turn_id}, at ${e.at}/${p.at}) (${o})`)}}let i=E(t,o);ee(i,{recursive:!0});let d=(s?.now??(()=>new Date))(),b=d.toISOString(),l={schema:N,kind:"delta",sid:o,seq:e.seq,turn_id:e.turn_id,at:e.at,ts:b,agent:{agent_state_schema:e.agent_state_schema,delta_items:e.delta_items,binding:e.binding,usage_total:e.usage_total,...e.base_fingerprint!==void 0?{base_fingerprint:e.base_fingerprint}:{}},kane:r},k=Math.max(1,s?.retries??ue),g=JSON.stringify(l)+`
4
4
  `,O=!1;Buffer.byteLength(g)>524288&&!J.has(o)&&(J.add(o),O=!0,s?.onSoftCap?.("note: this session's checkpoints are getting large \u2014 long pasted inputs are kept verbatim; consider ingesting big documents as sources instead"));let R=!1,v;for(let c=0;c<k&&!R;c++)try{F(m(i,y(e.seq)),g,i),R=!0}catch(u){v=u}if(!R)throw new S(`delta-${e.seq} write failed after ${k} attempts: ${v?.message??"unknown"} (${o})`);let h=p?.full_seq??null,$=G(i)>67108864;if(e.seq%25===0||$){let c=[],u=e.base_fingerprint;if(p){let C=se(t,o,p);c=C.items,u=u??C.base_fingerprint}if(c=[...c,...e.delta_items],!u)throw new S(`compaction at seq ${e.seq}: no base_fingerprint anywhere in the chain (${o})`);let f={...l,kind:"full",agent:{...l.agent,delta_items:c,base_fingerprint:u}};F(m(i,w(e.seq)),JSON.stringify(f)+`
5
5
  `,i),h=e.seq}let q={seq:e.seq,turn_id:e.turn_id,at:e.at,ts:b,full_seq:h};if(n.save({checkpoint:q}),h===e.seq){let{deltas:c,fulls:u}=re(t,o);for(let f of c)f<=h&&K(m(i,y(f)),{force:!0});for(let f of u)f<h&&K(m(i,w(f)),{force:!0})}let T=G(i);if($&&T>67108864)throw z(o,q,d),new j(`session ${o} checkpoint dir is ${Math.round(T/(1024*1024))}MB (cap ${Math.round(67108864/(1024*1024))}MB) even after compaction \u2014 pausing; resume in a fresh session or trim the conversation`);return z(o,q,d),s?.onStat?.({sid:o,seq:e.seq,persist_ms:performance.now()-a,bytes:Buffer.byteLength(g),dir_bytes:T,compacted:h===e.seq,soft_warned:O}),q}function Pe(t,n,e){let r=e?._readPointer??(()=>me(t,n)),s=m(E(t,n),P);if(!Z(s))throw new A("CHECKPOINT_MISSING",`${n}: no ${P} \u2014 not a checkpoint session`);let a=M(t,n,P),o=i=>{let{deltas:d,fulls:b}=re(t,n);if(!i){let g=[...d.map(y),...b.map(w)];return{base:a,agent:null,kane:null,pointer:null,orphans:g}}let l=se(t,n,i),k=[...d.filter(g=>g>i.seq).map(y),...b.filter(g=>g>i.seq).map(w)];return{base:a,agent:{delta_items:l.items,binding:l.last.agent.binding,base_fingerprint:l.base_fingerprint,agent_state_schema:l.last.agent.agent_state_schema},kane:l.last.kane,pointer:i,orphans:k,...l.fallback?{fallback:l.fallback}:{}}},p=r();try{return o(p)}catch(i){if(!(i.code==="ENOENT"))throw i;return o(r())}}function Ee(t,n){let e=[];for(let r of I(t).records)if(r.sid===n)for(let s of r.event_ids??[])e.push(s);return e}function ve(t,n,e,r,s){let a=s.verb??"extract",o=I(t),p=0;if(e.store_watermark!==null){let c=o.hashes.indexOf(e.store_watermark);if(c===-1)throw new V(`watermark not in chain: ${e.store_watermark} names no record in this store (rebuilt or foreign?) \u2014 re-ground the session or abandon it`);p=c+1}let i=L(t,{seq:p,hash:e.store_watermark}).records,d=o.records.filter(c=>c.sid===n).map(c=>c.seq),b=c=>d.filter(u=>u<=c.seq).length,l=new Set(e.applied_events),k=0,g=[];for(let c of i){if(typeof c.sid!="string"){k+=1;continue}if(c.sid===n){if((c.event_ids??[]).length===0){k+=1;continue}g.push(c)}}k>0&&s.onNote?.(`reconcile: skipped ${k} store record(s) not attributable to this session (pre-sid grace)`);let O=s.ownActors??["extract-agent","design-agent","owner"],R=[],v=[];for(let c of g){let u=(c.event_ids??[]).filter(ie=>!l.has(ie));if(u.length===0)continue;v.push(...u);let f;try{f=s.composeReceipt(c,r,{verb:a,commitN:b(c),...s.ucRef?{ucRef:s.ucRef}:{}}).text}catch{f=`commit ${u[0]} at ${c.ts} \u2014 details unavailable (graph moved since)`}let C=c.review?.[0]?.by;C?.id&&!O.includes(C.id)&&(f+=`
@@ -0,0 +1,4 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{b as N,c as O,e as S,f as D,j as T,n as y,p as z,r as U}from"./chunk-T4OJX2GZ.js";import{a as Y,b as M}from"./chunk-NBXYL2JT.js";import{a as F}from"./chunk-KRL2BDI5.js";import{a as R}from"./chunk-DPUV6OSP.js";import{a as A}from"./chunk-DEUDRSU7.js";import{e as $}from"./chunk-UR6MHSHU.js";var C=$(Y(),1);import{existsSync as k,readFileSync as I,readdirSync as J,statSync as K}from"fs";import{dirname as H,isAbsolute as V,join as h,relative as P,resolve as Z,sep as _}from"path";import{createHash as q}from"crypto";var b="testmd-bundle.json",u=class extends Error{constructor(t){super(t),this.name="BundleUsageError"}},B=e=>e.split(_).join("/");function v(e){if(!k(e))return[];let t=[];for(let s of J(e).sort()){let r=h(e,s);K(r).isDirectory()?t.push(...v(r)):t.push(r)}return t}function G(e){let t=e.map(r=>H(r).split(_)),s=t[0];for(let r of t.slice(1)){let i=0;for(;i<s.length&&i<r.length&&s[i]===r[i];)i++;s=s.slice(0,i)}return s.join(_)||_}function Q(e){for(let t of e){let s=F(t,I(t,"utf8"));for(let r of s.steps)if(r.body.kind==="import_ref"&&V(r.body.path))throw new u(`bundle sync: absolute @import is not portable after unzip: ${t} step ${r.index} (@import ${r.body.path})`)}}function j(e,t={}){let s=Z(e),r=S(s),i=y(s);if(!i?.commit_id||!i?.test_id)throw new u(`bundle sync: ${s} is not authored \u2014 run \`kane-cli testmd run\` first (output-<stem>/.internal/meta.json needs commit_id + test_id)`);let l;try{l=U(s)}catch(n){throw n instanceof z?new u(`bundle sync: ${n.message}`):n}let c=[s];for(let n of l.steps)for(let a of n.trace.slice(1))c.includes(a.file)||c.push(a.file);Q(c);let o=[],d=[];for(let n of l.unitFiles){if(n.file===s)continue;let a=N(n.file);o.includes(a)||o.push(a),n.kind==="module"&&d.push(S(n.file))}let m=[...c],p=n=>{k(n)&&m.push(n)};p(O(s)),m.push(r),p(D(s)),m.push(...v(T(s)));for(let n of o)p(h(n,"Result.md")),m.push(...v(h(n,".internal","steps")));for(let n of d)p(n);let f=G(m);if(k(h(f,b)))throw new u(`bundle sync: a real file named ${b} exists at the zip root (${f}) \u2014 it would collide with the generated manifest`);let w=m.map(n=>{let a=n===r&&t.identityOverride?Buffer.from(JSON.stringify({...JSON.parse(I(n,"utf8")),commit_id:t.identityOverride.commit_id},null,2)+`
3
+ `):void 0,E=a??I(n);return{abs:n,rel:B(P(f,n)),sha256:q("sha256").update(E).digest("hex"),bytes:E.length,...a?{contents:a}:{}}}).sort((n,a)=>n.rel<a.rel?-1:1),x=B(P(f,s)),L={schema_version:2,entry:x,commit_id:t.identityOverride?.commit_id??i.commit_id,test_id:i.test_id,testcase_id:i.testcase_id??null,project_id:i.project_id??null,folder_id:i.folder_id??null,org_id:i.org_id??null,created_at:new Date().toISOString(),producer:{name:"kane-cli",version:A},files:w.map(n=>({path:n.rel,sha256:n.sha256,bytes:n.bytes})),units:l.unitFiles.filter(n=>n.file!==s).map(n=>({path:B(P(f,n.file)),kind:n.kind}))};return{zipRoot:f,entry:x,files:w,manifest:L}}var g=e=>e instanceof Error?e.message:String(e);function W(e){return new Promise((t,s)=>{let r=(0,C.default)("zip",{zlib:{level:6}}),i=[];r.on("data",l=>i.push(l)),r.on("error",s),r.on("end",()=>t(Buffer.concat(i))),r.append(JSON.stringify(e.manifest,null,2)+`
4
+ `,{name:b});for(let l of e.files)l.contents?r.append(l.contents,{name:l.rel}):r.file(l.abs,{name:l.rel});r.finalize()})}async function X(e){let{plan:t,controller:s,testId:r,sessionId:i,commitId:l}=e,c;try{c=await W(t)}catch(d){return{ok:!1,stage:"zip",error:g(d)}}let o;try{let d={key:"testmd",content_type:"application/zip",filename:`${l}-testmd.zip`},p=(await s.getPresignedUrls(r,i,[d])).urls?.testmd?.upload_url;if(!p)return{ok:!1,stage:"presign",error:"presign response missing testmd upload_url"};o=p}catch(d){return{ok:!1,stage:"presign",error:g(d)}}try{await M(o,c,"application/zip")}catch(d){return{ok:!1,stage:"upload",error:g(d)}}return{ok:!0,bytes:c.length}}async function ee(e){let t;try{t=j(e.sourcePath,{identityOverride:e.identityOverride})}catch(s){return s instanceof u?{ok:!1,stage:"collect",error:s.message}:{ok:!1,stage:"collect",error:g(s)}}return X({...e,plan:t})}function ge(e){return e.shouldUploadPipeline&&e.uploadSucceeded&&!!e.metaCommitId&&!!e.metaTestId}function te(e){return e.persisted?e.uploadSucceeded?e.local?"local":e.hasBasicAuth?!e.metaCommitId||!e.metaTestId?"not_authored":null:"no_auth":"upload_failed":"not_persisted"}async function ye(e){let t=e.recordedTestPath??null,s=t?y(t):null,r=te({persisted:!!t,uploadSucceeded:e.uploadSucceeded,local:e.local,hasBasicAuth:!!e.basicAuth,metaCommitId:s?.commit_id,metaTestId:s?.test_id});if(r)return e.log("info","BUNDLE_SYNC_SKIPPED","testmd bundle sync skipped",{reason:r,...t?{path:t}:{}}),{skipped:r};let i=s.commit_id,l=s.test_id,c=o=>{try{e.onAgentEvent?.(o)}catch{}};try{let o=await(e.syncFn??ee)({sourcePath:t,testId:l,sessionId:e.sessionId,commitId:i,controller:new R(e.controllerBaseUrl,{username:e.basicAuth.username,accessKey:e.basicAuth.access_key})});return o.ok?(e.log("info","BUNDLE_SYNC_OK","testmd bundle pushed",{commit_id:i,path:t,bytes:o.bytes}),c({type:"test_md_bundle_sync",status:"ok",commit_id:i,path:t,bytes:o.bytes})):(e.log("warn","BUNDLE_SYNC_FAILED","testmd bundle sync failed",{commit_id:i,path:t,stage:o.stage,error:o.error}),c({type:"test_md_bundle_sync",status:"failed",commit_id:i,path:t,stage:o.stage})),o}catch(o){let d=g(o);return e.log("warn","BUNDLE_SYNC_FAILED","testmd bundle sync threw",{commit_id:i,path:t,error:d}),c({type:"test_md_bundle_sync",status:"failed",commit_id:i,path:t,stage:"upload"}),{ok:!1,stage:"upload",error:d}}}export{j as a,W as b,X as c,ee as d,ge as e,te as f,ye as g};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as R}from"./chunk-7RAIRUXO.js";import{x as i}from"./chunk-DWHXXPDX.js";import{a as Y}from"./chunk-HCBYKLMW.js";import{a,b as l,i as X}from"./chunk-C44QQJR4.js";import{a as K}from"./chunk-6YGTRKDT.js";import{e as P}from"./chunk-UR6MHSHU.js";var x=P(K(),1);var e=P(Y(),1),f=5;function Z(t,S){if(!S)return t;let c=S.toLowerCase();return t.filter(B=>B.label.toLowerCase().includes(c))}function Q(t){let{title:S,items:c,loading:B=!1,loadingText:p,error:L=null,itemNoun:v="items",onSelect:O,onCancel:E,defaultActiveId:w,onTab:y,extraHint:H}=t,[g,s]=(0,x.useState)(0),[h,u]=(0,x.useState)(0),[d,A]=(0,x.useState)(""),[C,I]=(0,x.useState)(null),N=!t.onSearch&&d!=="";(0,x.useEffect)(()=>{if(c.length===0||N)return;if(t.preserveSelectionById&&C!==null){let o=c.findIndex(n=>n.id===C);if(o>=0){u(Math.floor(o/f)),s(o%f);return}}let r=w?c.findIndex(o=>o.id===w):c.findIndex(o=>o.isActive);r>=0?(u(Math.floor(r/f)),s(r%f),t.preserveSelectionById&&I(c[r].id)):t.preserveSelectionById&&(u(0),s(0),I(c[0]?.id??null))},[c,w,t.preserveSelectionById,C,N]),(0,x.useEffect)(()=>{if(!t.onSearch)return;let r=setTimeout(()=>t.onSearch(d),t.searchDebounceMs??250);return()=>clearTimeout(r)},[d,t.onSearch,t.searchDebounceMs]);let b=t.onSearch?c:Z(c,d),D=h*f,F=Math.min(D+f,b.length),M=Math.ceil(b.length/f),$=F-D,T=b.slice(D,F);return X((r,o)=>{if(L){o.escape&&E();return}if(o.escape){d?(A(""),s(0),u(0)):E();return}if(o.tab&&y){y();return}if(o.upArrow){if(g>0){let n=g-1;s(n),t.preserveSelectionById&&I(T[n]?.id??null)}else if(h>0){let n=h-1,m=f-1;u(n),s(m),t.preserveSelectionById&&I(b[n*f+m]?.id??null)}return}if(o.downArrow){if(g<$-1){let n=g+1;s(n),t.preserveSelectionById&&I(T[n]?.id??null)}else if(h<M-1){let n=h+1,m=0;u(n),s(m),t.preserveSelectionById&&I(b[n*f+m]?.id??null)}return}if(o.return&&T[g]){if(T[g].disabled)return;O(T[g]);return}if(o.backspace||o.delete){A(n=>n.slice(0,-1)),s(0),u(0);return}r&&!o.ctrl&&!o.meta&&(A(n=>n+r),s(0),u(0))},{isActive:!B}),B?(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:i.orange,paddingX:2,paddingY:1,children:[(0,e.jsx)(l,{color:i.orange,bold:!0,children:S}),(0,e.jsx)(a,{marginTop:1,children:(0,e.jsx)(l,{color:i.secondary,children:p??`Loading ${v}\u2026`})})]}):L?(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:i.red,paddingX:2,paddingY:1,children:[(0,e.jsx)(l,{color:i.red,bold:!0,children:S}),(0,e.jsx)(a,{marginTop:1,children:(0,e.jsx)(l,{color:i.red,children:L})}),(0,e.jsx)(R,{bindings:[]})]}):(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:i.orange,paddingX:2,paddingY:1,children:[(0,e.jsxs)(a,{children:[(0,e.jsx)(l,{color:i.orange,bold:!0,children:S}),(0,e.jsxs)(l,{color:i.dim,children:[" (",b.length,!t.onSearch&&d?`/${c.length}`:""," ",v,t.loadingMore?" \xB7 loading more":"",")"]})]}),(0,e.jsxs)(a,{marginTop:1,children:[(0,e.jsx)(l,{color:i.secondary,children:d?"filter: ":""}),d?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(l,{children:d}),(0,e.jsx)(l,{inverse:!0,children:" "})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(l,{color:i.dim,children:["Search ",v,"\u2026"]}),(0,e.jsx)(l,{inverse:!0,children:" "})]})]}),(0,e.jsx)(a,{flexDirection:"column",marginTop:1,children:t.searching?(0,e.jsxs)(l,{color:i.secondary,children:["Searching ",v,"\u2026"]}):b.length===0?(0,e.jsxs)(l,{color:i.dim,children:["No ",v,' match "',d,'"']}):T.map((r,o)=>{let n=o===g,m=n?"\u276F ":" ",G=r.disabled?i.muted:r.isActive?i.green:n?i.orange:void 0;return(0,e.jsxs)(a,{flexDirection:"column",children:[(0,e.jsxs)(l,{color:G,children:[m,r.label,r.isActive&&!r.disabled?" \u25CF selected":""]}),n&&r.disabled&&r.disabledHint&&(0,e.jsxs)(l,{color:i.red,children:[" ",r.disabledHint]})]},r.id)})}),!t.searching&&M>1&&(0,e.jsx)(a,{marginTop:1,children:(0,e.jsxs)(l,{color:i.dim,children:["Page ",h+1,"/",M]})}),t.footer&&(0,e.jsx)(a,{marginTop:1,flexDirection:"column",children:t.footer}),(0,e.jsx)(R,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"type",label:"to search"},{keys:"\u21B5",label:"select"},...y&&H?[{keys:"tab",label:H}]:[]],escBackLabel:d?"clear":"back to chat"})]})}export{Q as a};
2
+ import{a as R}from"./chunk-5NBT5IVT.js";import{x as i}from"./chunk-DEUDRSU7.js";import{a as Y}from"./chunk-HCBYKLMW.js";import{a,b as l,i as X}from"./chunk-C44QQJR4.js";import{a as K}from"./chunk-6YGTRKDT.js";import{e as P}from"./chunk-UR6MHSHU.js";var x=P(K(),1);var e=P(Y(),1),f=5;function Z(t,S){if(!S)return t;let c=S.toLowerCase();return t.filter(B=>B.label.toLowerCase().includes(c))}function Q(t){let{title:S,items:c,loading:B=!1,loadingText:p,error:L=null,itemNoun:v="items",onSelect:O,onCancel:E,defaultActiveId:w,onTab:y,extraHint:H}=t,[g,s]=(0,x.useState)(0),[h,u]=(0,x.useState)(0),[d,A]=(0,x.useState)(""),[C,I]=(0,x.useState)(null),N=!t.onSearch&&d!=="";(0,x.useEffect)(()=>{if(c.length===0||N)return;if(t.preserveSelectionById&&C!==null){let o=c.findIndex(n=>n.id===C);if(o>=0){u(Math.floor(o/f)),s(o%f);return}}let r=w?c.findIndex(o=>o.id===w):c.findIndex(o=>o.isActive);r>=0?(u(Math.floor(r/f)),s(r%f),t.preserveSelectionById&&I(c[r].id)):t.preserveSelectionById&&(u(0),s(0),I(c[0]?.id??null))},[c,w,t.preserveSelectionById,C,N]),(0,x.useEffect)(()=>{if(!t.onSearch)return;let r=setTimeout(()=>t.onSearch(d),t.searchDebounceMs??250);return()=>clearTimeout(r)},[d,t.onSearch,t.searchDebounceMs]);let b=t.onSearch?c:Z(c,d),D=h*f,F=Math.min(D+f,b.length),M=Math.ceil(b.length/f),$=F-D,T=b.slice(D,F);return X((r,o)=>{if(L){o.escape&&E();return}if(o.escape){d?(A(""),s(0),u(0)):E();return}if(o.tab&&y){y();return}if(o.upArrow){if(g>0){let n=g-1;s(n),t.preserveSelectionById&&I(T[n]?.id??null)}else if(h>0){let n=h-1,m=f-1;u(n),s(m),t.preserveSelectionById&&I(b[n*f+m]?.id??null)}return}if(o.downArrow){if(g<$-1){let n=g+1;s(n),t.preserveSelectionById&&I(T[n]?.id??null)}else if(h<M-1){let n=h+1,m=0;u(n),s(m),t.preserveSelectionById&&I(b[n*f+m]?.id??null)}return}if(o.return&&T[g]){if(T[g].disabled)return;O(T[g]);return}if(o.backspace||o.delete){A(n=>n.slice(0,-1)),s(0),u(0);return}r&&!o.ctrl&&!o.meta&&(A(n=>n+r),s(0),u(0))},{isActive:!B}),B?(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:i.orange,paddingX:2,paddingY:1,children:[(0,e.jsx)(l,{color:i.orange,bold:!0,children:S}),(0,e.jsx)(a,{marginTop:1,children:(0,e.jsx)(l,{color:i.secondary,children:p??`Loading ${v}\u2026`})})]}):L?(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:i.red,paddingX:2,paddingY:1,children:[(0,e.jsx)(l,{color:i.red,bold:!0,children:S}),(0,e.jsx)(a,{marginTop:1,children:(0,e.jsx)(l,{color:i.red,children:L})}),(0,e.jsx)(R,{bindings:[]})]}):(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:i.orange,paddingX:2,paddingY:1,children:[(0,e.jsxs)(a,{children:[(0,e.jsx)(l,{color:i.orange,bold:!0,children:S}),(0,e.jsxs)(l,{color:i.dim,children:[" (",b.length,!t.onSearch&&d?`/${c.length}`:""," ",v,t.loadingMore?" \xB7 loading more":"",")"]})]}),(0,e.jsxs)(a,{marginTop:1,children:[(0,e.jsx)(l,{color:i.secondary,children:d?"filter: ":""}),d?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(l,{children:d}),(0,e.jsx)(l,{inverse:!0,children:" "})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(l,{color:i.dim,children:["Search ",v,"\u2026"]}),(0,e.jsx)(l,{inverse:!0,children:" "})]})]}),(0,e.jsx)(a,{flexDirection:"column",marginTop:1,children:t.searching?(0,e.jsxs)(l,{color:i.secondary,children:["Searching ",v,"\u2026"]}):b.length===0?(0,e.jsxs)(l,{color:i.dim,children:["No ",v,' match "',d,'"']}):T.map((r,o)=>{let n=o===g,m=n?"\u276F ":" ",G=r.disabled?i.muted:r.isActive?i.green:n?i.orange:void 0;return(0,e.jsxs)(a,{flexDirection:"column",children:[(0,e.jsxs)(l,{color:G,children:[m,r.label,r.isActive&&!r.disabled?" \u25CF selected":""]}),n&&r.disabled&&r.disabledHint&&(0,e.jsxs)(l,{color:i.red,children:[" ",r.disabledHint]})]},r.id)})}),!t.searching&&M>1&&(0,e.jsx)(a,{marginTop:1,children:(0,e.jsxs)(l,{color:i.dim,children:["Page ",h+1,"/",M]})}),t.footer&&(0,e.jsx)(a,{marginTop:1,flexDirection:"column",children:t.footer}),(0,e.jsx)(R,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"type",label:"to search"},{keys:"\u21B5",label:"select"},...y&&H?[{keys:"tab",label:H}]:[]],escBackLabel:d?"clear":"back to chat"})]})}export{Q as a};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as k}from"./chunk-SJBIXLL3.js";import{x as u}from"./chunk-DWHXXPDX.js";import{a as f}from"./chunk-HCBYKLMW.js";import{a as m,b as s,k as b}from"./chunk-C44QQJR4.js";import{e as p}from"./chunk-UR6MHSHU.js";function B(t){let e=t;return e=e.replace(/@TS\{([^}]+)\}/g,"@S{$1}"),e=e.replace(/@TS-(\d+)/g,(o,i)=>`@S${parseInt(i,10)}.C1`),e=e.replace(/@TS(\d+)/g,(o,i)=>`@S${parseInt(i,10)}`),e=e.replace(/\\n/g,`
2
+ import{a as k}from"./chunk-A76UL3EN.js";import{x as u}from"./chunk-DEUDRSU7.js";import{a as f}from"./chunk-HCBYKLMW.js";import{a as m,b as s,k as b}from"./chunk-C44QQJR4.js";import{e as p}from"./chunk-UR6MHSHU.js";function B(t){let e=t;return e=e.replace(/@TS\{([^}]+)\}/g,"@S{$1}"),e=e.replace(/@TS-(\d+)/g,(o,i)=>`@S${parseInt(i,10)}.C1`),e=e.replace(/@TS(\d+)/g,(o,i)=>`@S${parseInt(i,10)}`),e=e.replace(/\\n/g,`
3
3
  `),e}var c=p(f(),1),S=t=>t!==void 0&&/[A-Za-z0-9]/.test(t);function x(t){let e=[],o="",i=()=>{o&&(e.push({text:o}),o="")},d=(a,l,r)=>(a===0||!S(t[a-1]))&&(l+r>=t.length||!S(t[l+r])),n=0;for(;n<t.length;){let a=t.slice(n,n+2),l=t[n];if(a==="**"||a==="__"){let r=t.indexOf(a,n+2);if(r!==-1&&r>n+2&&(a==="**"||d(n,r,2))){i(),e.push({text:t.slice(n+2,r),bold:!0}),n=r+2;continue}}if(l==="`"){let r=t.indexOf("`",n+1);if(r!==-1&&r>n+1){i(),e.push({text:t.slice(n+1,r),code:!0}),n=r+1;continue}}if(l==="*"||l==="_"){let r=t.indexOf(l,n+1);if(r!==-1&&r>n+1&&(l==="*"||d(n,r,1))){i(),e.push({text:t.slice(n+1,r),italic:!0}),n=r+1;continue}}o+=l,n+=1}return i(),e.length===0&&e.push({text:""}),e}function h(t){return t.map((e,o)=>(0,c.jsx)(s,{bold:e.bold,italic:e.italic,color:e.code?u.dim:void 0,children:e.text},o))}function T(t){return t.split(`
4
4
  `).map(e=>{if(e.trim()==="")return{kind:"blank"};let o=e.match(/^\s*[-*+]\s+(.*)$/);if(o)return{kind:"bullet",segs:x(o[1])};let i=e.match(/^\s*(\d+)\.\s+(.*)$/);if(i)return{kind:"numbered",n:i[1],segs:x(i[2])};let d=e.match(/^#{1,6}\s+(.*)$/);return d?{kind:"heading",segs:x(d[1])}:{kind:"para",segs:x(e)}})}function R(t,e,o=""){switch(t.kind){case"blank":return(0,c.jsx)(s,{children:o||" "},e);case"heading":return(0,c.jsxs)(s,{bold:!0,children:[o,h(t.segs)]},e);case"bullet":return(0,c.jsx)(m,{marginLeft:1,children:(0,c.jsxs)(s,{children:[o,"\u2022 ",h(t.segs)]})},e);case"numbered":return(0,c.jsx)(m,{marginLeft:1,children:(0,c.jsxs)(s,{children:[o,`${t.n}. `,h(t.segs)]})},e);default:return(0,c.jsxs)(s,{children:[o,h(t.segs)]},e)}}function $({text:t,accent:e=u.generateAccent}){let o=T(B(t)),{stdout:i}=b(),d=i?.columns??80;return(0,c.jsxs)(m,{marginBottom:1,children:[(0,c.jsx)(m,{width:2,flexShrink:0,children:(0,c.jsx)(s,{color:e,children:"\u2503"})}),(0,c.jsx)(m,{flexDirection:"column",width:d-2,children:o.map((n,a)=>R(n,a))})]})}var g=p(f(),1),I=5;function C({thinking:t,expanded:e,thinkingDone:o,maxLines:i=I}){if(!e)return(0,g.jsxs)(m,{paddingX:1,children:[(0,g.jsx)(s,{color:u.dim,children:o?"\u2237 thinking complete ":"\u2237 thinking\u2026 "}),(0,g.jsx)(s,{color:u.muted,children:o?"(ctrl+t to view)":"(ctrl+t to show)"})]});let d=t.split(`
5
5
  `),n=Math.max(0,d.length-i),a=n>0?d.slice(-i).join(`
@@ -1,4 +1,4 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as j}from"./chunk-UH2ZTX4E.js";import{a as E,e as O,h as A}from"./chunk-XMTSHHYQ.js";import{a as S,e as N,f as F,g as L,h as C}from"./chunk-AKX4VRRR.js";import{existsSync as y,mkdirSync as G,readFileSync as q,renameSync as H,rmSync as J,writeFileSync as K}from"fs";import{dirname as W,join as w}from"path";var D=o=>w(o,"derived"),x=o=>w(D(o),"index.json");function U(o,s){let r=s.startsWith("sha256:")?s.slice(7):s;return w(D(o),"nodes",r.slice(0,2),r.slice(2)+".json")}function k(){return{applied:{seq:0,hash:null},heads:{},trust:{},nodeLabel:{},forward:{},extracted:[],design_of:{},design_generation:{},exec:{},superseded:{},names:{},archivedReason:{},appliedEvents:[],completeness:{},srcOwner:{},conv:{},media:{},design_phases:{},edgeRetractions:{}}}function P(o){let s=x(o);if(!y(s))return null;try{let r=JSON.parse(q(s,"utf8"));return r.superseded===void 0||r.names===void 0||r.archivedReason===void 0||r.appliedEvents===void 0||r.conv===void 0||r.media===void 0||r.exec===void 0||r.completeness===void 0||r.srcOwner===void 0||r.design_phases===void 0||r.edgeRetractions===void 0||r.reverse!==void 0?null:r}catch{return null}}function V(o,s){G(W(o),{recursive:!0});let r=`${o}.tmp-${process.pid}`;K(r,s),H(r,o)}function b(o,s,r,p,h={}){let a=h.writeNodeFiles!==!1,g=new Set(s.extracted),v=new Set(s.appliedEvents);r.forEach((n,R)=>{for(let e of n.nodes){let d=U(o,e.cid);a&&!y(d)&&V(d,JSON.stringify({label:e.label,content:e.content})+`
2
+ import{a as j}from"./chunk-TYRTD5DD.js";import{a as E,e as O,h as A}from"./chunk-OXHMUZJV.js";import{a as S,e as N,f as F,g as L,h as C}from"./chunk-AKX4VRRR.js";import{existsSync as y,mkdirSync as G,readFileSync as q,renameSync as H,rmSync as J,writeFileSync as K}from"fs";import{dirname as W,join as w}from"path";var D=o=>w(o,"derived"),x=o=>w(D(o),"index.json");function U(o,s){let r=s.startsWith("sha256:")?s.slice(7):s;return w(D(o),"nodes",r.slice(0,2),r.slice(2)+".json")}function k(){return{applied:{seq:0,hash:null},heads:{},trust:{},nodeLabel:{},forward:{},extracted:[],design_of:{},design_generation:{},exec:{},superseded:{},names:{},archivedReason:{},appliedEvents:[],completeness:{},srcOwner:{},conv:{},media:{},design_phases:{},edgeRetractions:{}}}function P(o){let s=x(o);if(!y(s))return null;try{let r=JSON.parse(q(s,"utf8"));return r.superseded===void 0||r.names===void 0||r.archivedReason===void 0||r.appliedEvents===void 0||r.conv===void 0||r.media===void 0||r.exec===void 0||r.completeness===void 0||r.srcOwner===void 0||r.design_phases===void 0||r.edgeRetractions===void 0||r.reverse!==void 0?null:r}catch{return null}}function V(o,s){G(W(o),{recursive:!0});let r=`${o}.tmp-${process.pid}`;K(r,s),H(r,o)}function b(o,s,r,p,h={}){let a=h.writeNodeFiles!==!1,g=new Set(s.extracted),v=new Set(s.appliedEvents);r.forEach((n,R)=>{for(let e of n.nodes){let d=U(o,e.cid);a&&!y(d)&&V(d,JSON.stringify({label:e.label,content:e.content})+`
3
3
  `),!(e.cid in s.trust)&&e.content.derived===!0&&(s.trust[e.cid]="derived"),s.nodeLabel[e.cid]=e.label}for(let[e,d]of Object.entries(n.source_head_moves))typeof d=="string"&&(s.srcOwner[d]=e);if(n.proposal_id!=null&&typeof n.extraction_of=="string"){g.add(n.extraction_of);let e=null;for(let d of n.edges)if(d.type===N.DERIVES&&d.props.source_cid===n.extraction_of&&typeof d.props.source_id=="string"){e=d.props.source_id;break}if(e??=s.srcOwner[n.extraction_of]??null,e!==null){let d=s.completeness[e];(!d||n.seq>=d.seq)&&(s.completeness[e]={source_cid:n.extraction_of,completeness:"complete",...n.extractor_version?{extractor_version:n.extractor_version}:{},at:n.ts,seq:n.seq})}else s.completenessSkipped=(s.completenessSkipped??0)+1}else if(n.proposal_id!=null&&Array.isArray(n.extraction_of))for(let e of n.extraction_of){g.add(e.source_cid);let d=s.completeness[e.source_id];(!d||n.seq>=d.seq)&&(s.completeness[e.source_id]={source_cid:e.source_cid,completeness:e.completeness,...e.extractor_version?{extractor_version:e.extractor_version}:{},at:e.at,seq:n.seq})}n.design_of&&((s.design_of??={})[n.design_of.uc_cid]={engine:n.design_of.engine,seq:n.seq}),n.design_generation&&((s.design_generation??={})[n.design_generation.uc_root]={gen:n.design_generation.generation,seq:n.seq});{let e=n.design_phase;e&&typeof e.uc_root=="string"&&typeof e.phase=="string"&&typeof e.generation=="number"&&((s.design_phases??={})[e.uc_root]??=[]).push({phase:e.phase,generation:e.generation,seq:n.seq,completeness:e.completeness==="partial"?"partial":"complete"})}for(let e of n.executions??[])((s.exec??={})[e.about]??=[]).push(e);for(let e of n.edges){let{quote:d,...m}=e.props,i=s.forward[e.src]??=[];i.some(t=>t.ecid===e.ecid)||i.push({...e,props:m}),n.proposal_id!=null&&e.type===N.DERIVES&&typeof e.props.source_cid=="string"&&g.add(e.props.source_cid)}for(let e of n.review)e.resolution==="approved"||e.resolution==="edited"?(s.trust[e.id]="trusted",delete s.archivedReason[e.id]):e.resolution==="rejected"?(s.trust[e.id]="archived",e.reason?s.archivedReason[e.id]=e.reason:delete s.archivedReason[e.id]):e.resolution==="reset"&&(s.trust[e.id]="derived",delete s.archivedReason[e.id]);for(let e of n.supersessions)e.kind==="node"?e.new===e.old?delete s.superseded[e.old]:s.superseded[e.old]=e.new:e.revoke?(delete s.superseded[e.ecid],delete s.edgeRetractions[e.ecid]):(s.superseded[e.ecid]=null,s.edgeRetractions[e.ecid]={at:n.ts,...e.by?{by:e.by}:{},...e.reason?{reason:e.reason}:{}});for(let e of n.names??[])s.names[e.slug]=e.cid;for(let[e,d]of Object.entries(n.source_head_moves))s.heads[e]=d;for(let e of n.event_ids??[])v.add(e);if(n.media)for(let[e,d]of Object.entries(n.media)){let m=n.source_head_moves[e];typeof m=="string"&&(s.media[m]=d)}if(n.conv){let e=n.source_head_moves[n.conv.source_id];if(typeof e=="string"){let d=s.conv[n.conv.source_id],m=d&&d.chain.length>0?d.chain[d.chain.length-1]:null;n.conv.append_of===m?s.conv[n.conv.source_id]={turns:n.conv.turn,chain:[...d?.chain??[],e]}:s.conv[n.conv.source_id]={turns:n.conv.turn,chain:[e]}}}for(let[e,d]of Object.entries(n.source_head_moves))n.conv?.source_id!==e&&s.conv[e]!==void 0&&(s.conv[e]=typeof d=="string"?{turns:s.conv[e].turns,chain:[d]}:{turns:s.conv[e].turns,chain:[]});s.applied={seq:n.seq,hash:p[R]}}),s.extracted=[...g].sort(),s.appliedEvents=[...v].sort()}function T(o,s){V(x(o),JSON.stringify(s)+`
4
4
  `)}function B(o){let s=w(o,"meta.json");if(y(s))try{let r=JSON.parse(q(s,"utf8"));if(r.schema!==S||r.canonicalizer!=="v1")throw new E(`schema fence: store is ${r.schema}/${r.canonicalizer}, this build is ${S}/${"v1"} \u2014 migrate explicitly (kane-cli context rebuild after upgrading)`)}catch(r){throw r instanceof E?r:new E(`corrupt meta.json in ${o} \u2014 fix or remove it`)}}function Y(o){B(o);let s=P(o);if(s===null){s=k();let{records:h,hashes:a}=O(o);return b(o,s,h,a),T(o,s),s}let{records:r,hashes:p}=A(o,s.applied.seq,s.applied.hash);return r.length>0&&(b(o,s,r,p),T(o,s)),s}function ne(o){return J(D(o),{recursive:!0,force:!0}),Y(o)}var z=new Set(["CHAIN_ERROR","DERIVED_MISSING","DERIVED_DRIFT","NODE_FILE_MISSING","NODE_FILE_MISMATCH","NODE_FILE_CORRUPT"]);function te(o){return z.has(o.code)?o.detail:`${o.code}: ${o.detail}`}function re(o){let s=[],r=(i,t)=>{s.push({code:i,detail:t})},p=[],h=[];try{({records:p,hashes:h}=O(o))}catch(i){return{ok:!1,issues:[{code:"CHAIN_ERROR",detail:i instanceof E?i.message:String(i)}],records:0}}let a=k();b(o,a,p,h,{writeNodeFiles:!1});let g=P(o),v=0,n=a;if(g!==null&&g.applied.seq<p.length){let i=g.applied.seq;g.applied.hash===(i===0?null:h[i-1])&&(v=p.length-i,n=k(),b(o,n,p.slice(0,i),h.slice(0,i),{writeNodeFiles:!1}))}if(g===null)r("DERIVED_MISSING","derived/index.json missing or corrupt (run kane-cli context rebuild)");else{let i=t=>JSON.stringify($(t));for(let t of["applied","heads","trust","nodeLabel","forward","extracted","superseded","names","archivedReason","appliedEvents","conv","media","design_of","design_generation","design_phases","exec","completeness","srcOwner","edgeRetractions"])i(n[t])!==i(g[t])&&r("DERIVED_DRIFT",`derived drift in index.${t} (run kane-cli context rebuild)`)}let R=new Set;for(let i of Object.values(a.forward))for(let t of i)R.add(t.ecid);let e=new Set,d=new Set;for(let i of p)for(let t of i.supersessions)t.kind==="node"?(t.old in a.nodeLabel||r("SUPERSEDE_UNKNOWN_OLD",`${t.old} (record ${i.seq})`),t.new!==null&&t.new!==t.old&&!(t.new in a.nodeLabel)&&r("SUPERSEDE_UNKNOWN_NEW",`${String(t.new)} (record ${i.seq})`),t.new===t.old?e.delete(t.old):(e.has(t.old)&&r("DOUBLE_SUPERSEDE",`${t.old} re-superseded while live (record ${i.seq})`),e.add(t.old))):(R.has(t.ecid)||r("SUPERSEDE_UNKNOWN_ECID",`${t.ecid} (record ${i.seq})`),t.revoke?(d.has(t.ecid)||r("EDGE_ORPHAN_REVOKE",`${t.ecid} revoked without a standing retraction (record ${i.seq})`),d.delete(t.ecid)):(d.has(t.ecid)&&r("EDGE_DOUBLE_RETRACT",`${t.ecid} re-retracted while already retracted (record ${i.seq})`),d.add(t.ecid)));for(let i of Object.keys(a.superseded)){let t=new Set,l=i;for(;l!==null&&l in a.superseded;){if(t.has(l)){r("SUPERSEDE_CYCLE",`chain from ${i} revisits ${l}`);break}t.add(l),l=a.superseded[l]}}for(let[i,t]of Object.entries(a.names))t in a.nodeLabel||r("NAME_UNKNOWN_TARGET",`slug ${i} \u2192 ${t} not in the graph`);for(let i of p)for(let t of i.edges){let l=a.nodeLabel[t.src]??"(unknown)",f=a.nodeLabel[t.dst]??"(unknown)";for(let c of C(t.type,l,f,t.props))r(c.code,`${t.ecid} ${c.detail}`)}let m=new Map;for(let i of Object.values(a.forward))for(let t of i){if(t.ecid in a.superseded)continue;let l=m.get(t.type)??[];l.push(t),m.set(t.type,l)}for(let[i,t]of m){let l=L(i);if(l?.acyclic){let f=new Map;for(let u of t)f.set(u.src,[...f.get(u.src)??[],u.dst]);let c=new Map,_=u=>{c.set(u,1);for(let I of f.get(u)??[])if(c.get(I)===1||c.get(I)===void 0&&_(I))return!0;return c.set(u,2),!1};for(let u of f.keys())if(c.get(u)===void 0&&_(u)){r("EDGE_CYCLE",`live ${i} edges form a cycle reachable from ${u}`);break}}if(l?.cardinality==="one-live-per-src"||l?.cardinality==="one-live-per-src-and-dst"){let f=new Map;for(let c of t)c.dst in a.superseded||f.set(c.src,[...f.get(c.src)??[],c]);for(let[c,_]of f)_.length>1&&r("CARDINALITY_VIOLATION",`${_.length} live ${i} edges from ${c} (one-live-per-src): ecids ${_.map(u=>u.ecid).join(",")}`)}if(l?.cardinality==="one-live-per-src-and-dst"){let f=new Map;for(let c of t)c.src in a.superseded||c.dst in a.superseded||f.set(c.dst,[...f.get(c.dst)??[],c]);for(let[c,_]of f)_.length>1&&r("CARDINALITY_VIOLATION",`${_.length} live ${i} edges onto ${c} (one-live-per-dst): ecids ${_.map(u=>u.ecid).join(",")}`)}}for(let[i,t]of Object.entries(n.nodeLabel)){let l=U(o,i);if(!y(l)){r("NODE_FILE_MISSING",`missing node file for ${i} (run kane-cli context rebuild)`);continue}try{let f=JSON.parse(q(l,"utf8"));(f.label!==t||j(f.label,f.content)!==i)&&r("NODE_FILE_MISMATCH",`node file content mismatch for ${i} (run kane-cli context rebuild)`);for(let c of F(f.label,f.content))r(c.code,`${i} ${c.detail}`)}catch{r("NODE_FILE_CORRUPT",`corrupt node file for ${i} (run kane-cli context rebuild)`)}}return{ok:s.length===0,issues:s,records:p.length,...v>0?{pending:v}:{}}}function $(o){return Array.isArray(o)?o.map($):o&&typeof o=="object"?Object.fromEntries(Object.entries(o).sort(([s],[r])=>s<r?-1:1).map(([s,r])=>[s,$(r)])):o}export{U as a,Y as b,ne as c,te as d,re as e};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as f}from"./chunk-WH5RVDD6.js";import{c as g}from"./chunk-UD7KKHPW.js";import{existsSync as u}from"fs";import{dirname as A,resolve as l}from"path";import{fileURLToPath as E}from"url";var p=A(E(import.meta.url));function _(){return[l(p,".."),l(p,"../../..")]}function x(s){return{"darwin-arm64":"kane-cli-darwin-arm64","darwin-x64":"kane-cli-darwin-x64","linux-x64":"kane-cli-linux-x64","linux-arm64":"kane-cli-linux-arm64","win32-x64":"kane-cli-win-x64"}[s]??null}function T(s){return{"darwin-arm64":"kane-cli-assurance-darwin-arm64","darwin-x64":"kane-cli-assurance-darwin-x64","linux-x64":"kane-cli-assurance-linux-x64","linux-arm64":"kane-cli-assurance-linux-arm64","win32-x64":"kane-cli-assurance-win-x64"}[s]??null}function I(s=_()){let n=x(`${process.platform}-${process.arch}`),i=T(`${process.platform}-${process.arch}`),a=process.platform==="win32"?"assurance-agent.exe":"assurance-agent";for(let e of s){for(let t of i?["@testmuai","@lambdatestincprivate"]:[]){let m=l(e,"node_modules",t,i,"bin",a);if(u(m))return{cmd:m,args:[],tier:"platform"}}for(let t of n?["@testmuai","@lambdatestincprivate"]:[]){let m=l(e,"node_modules",t,n,"bin",a);if(u(m))return{cmd:m,args:[],tier:"platform"}}let c=l(e,"dist","bin",a);if(u(c))return{cmd:c,args:[],tier:"embedded"};let r=l(e,"../assurance-agent/dist",a);if(u(r))return{cmd:r,args:[],tier:"sibling"};let o=l(e,"../assurance-agent/main.py");if(u(o)){let t=l(e,"../assurance-agent/.venv/bin/python");return{cmd:u(t)?t:"python3",args:[o],tier:"dev-python"}}}return null}function U(s,n={}){return{...process.env,...n,...f(),TESTMUAI_SOURCE:"kane-cli",TESTMUAI_SESSION_ID:s,ASSURANCE_LOG_LEVEL:process.env.ASSURANCE_LOG_LEVEL??"info"}}async function P(){if(process.env.TESTMUAI_API_KEY||process.env.TESTMUAI_BASIC_AUTH)return{};try{let{CredentialsManager:s}=await import("./credentials-YEWA7HXA.js"),n=process.env.TESTMUAI_ENV==="stage"?"stage":"prod",i=new s,a=i.getActiveProfile()??"default",e={TESTMUAI_ENV:n},c=i.loadBasicAuth(a,n);if(c)return e.TESTMUAI_BASIC_AUTH=Buffer.from(`${c.username}:${c.access_key}`,"utf8").toString("base64"),e;let r=i.loadCredentials(a,n);if(r){try{let{refreshOAuthToken:t}=await import("./token-refresh-ZFT457VI.js");await t({creds:i,profile:a,env:n,credentials:r})}catch{}let o=i.loadCredentials(a,n)??r;if(typeof o.access_token=="string"){let t=await w(n,o.access_token);return t?(e.TESTMUAI_BASIC_AUTH=t,e):(e.TESTMUAI_API_KEY=o.access_token,e)}}return{}}catch{return{}}}var h=8e3;function d(){return g("warn: session auth may expire during long runs \u2014 if that happens, run `kane-cli login` and retry","AUTH_EXCHANGE_FAILED"),null}async function w(s,n){try{let[{getEnvironment:i},{ControllerClient:a}]=await Promise.all([import("./config-ZDGCZZT3.js"),import("./controller-client-OB4WD2C4.js")]),e=new a(i(s).controllerBaseUrl,n),c;try{let r=await Promise.race([e.getTmsCredentials().catch(()=>null),new Promise(o=>{c=setTimeout(()=>o(null),h)})]);if(typeof r?.username!="string"||!r.username||typeof r.access_key!="string"||!r.access_key)return d();try{let[{refreshIdentitySnapshot:o},{telemetryEnvName:t}]=await Promise.all([import("./identity-ADZ4PAJF.js"),import("./bootstrap-MYG4TJVF.js")]);await o(t(),r)}catch{}return Buffer.from(`${r.username}:${r.access_key}`,"utf8").toString("base64")}finally{clearTimeout(c)}}catch{return d()}}export{x as a,T as b,I as c,U as d,P as e};
2
+ import{b as f}from"./chunk-7HUJVIMO.js";import{c as g}from"./chunk-UD7KKHPW.js";import{existsSync as u}from"fs";import{dirname as A,resolve as l}from"path";import{fileURLToPath as E}from"url";var p=A(E(import.meta.url));function _(){return[l(p,".."),l(p,"../../..")]}function x(s){return{"darwin-arm64":"kane-cli-darwin-arm64","darwin-x64":"kane-cli-darwin-x64","linux-x64":"kane-cli-linux-x64","linux-arm64":"kane-cli-linux-arm64","win32-x64":"kane-cli-win-x64"}[s]??null}function T(s){return{"darwin-arm64":"kane-cli-assurance-darwin-arm64","darwin-x64":"kane-cli-assurance-darwin-x64","linux-x64":"kane-cli-assurance-linux-x64","linux-arm64":"kane-cli-assurance-linux-arm64","win32-x64":"kane-cli-assurance-win-x64"}[s]??null}function I(s=_()){let n=x(`${process.platform}-${process.arch}`),i=T(`${process.platform}-${process.arch}`),a=process.platform==="win32"?"assurance-agent.exe":"assurance-agent";for(let e of s){for(let t of i?["@testmuai","@lambdatestincprivate"]:[]){let m=l(e,"node_modules",t,i,"bin",a);if(u(m))return{cmd:m,args:[],tier:"platform"}}for(let t of n?["@testmuai","@lambdatestincprivate"]:[]){let m=l(e,"node_modules",t,n,"bin",a);if(u(m))return{cmd:m,args:[],tier:"platform"}}let c=l(e,"dist","bin",a);if(u(c))return{cmd:c,args:[],tier:"embedded"};let r=l(e,"../assurance-agent/dist",a);if(u(r))return{cmd:r,args:[],tier:"sibling"};let o=l(e,"../assurance-agent/main.py");if(u(o)){let t=l(e,"../assurance-agent/.venv/bin/python");return{cmd:u(t)?t:"python3",args:[o],tier:"dev-python"}}}return null}function U(s,n={}){return{...process.env,...n,...f(),TESTMUAI_SOURCE:"kane-cli",TESTMUAI_SESSION_ID:s,ASSURANCE_LOG_LEVEL:process.env.ASSURANCE_LOG_LEVEL??"info"}}async function P(){if(process.env.TESTMUAI_API_KEY||process.env.TESTMUAI_BASIC_AUTH)return{};try{let{CredentialsManager:s}=await import("./credentials-BEC4I5SE.js"),n=process.env.TESTMUAI_ENV==="stage"?"stage":"prod",i=new s,a=i.getActiveProfile()??"default",e={TESTMUAI_ENV:n},c=i.loadBasicAuth(a,n);if(c)return e.TESTMUAI_BASIC_AUTH=Buffer.from(`${c.username}:${c.access_key}`,"utf8").toString("base64"),e;let r=i.loadCredentials(a,n);if(r){try{let{refreshOAuthToken:t}=await import("./token-refresh-IT4LVE2H.js");await t({creds:i,profile:a,env:n,credentials:r})}catch{}let o=i.loadCredentials(a,n)??r;if(typeof o.access_token=="string"){let t=await w(n,o.access_token);return t?(e.TESTMUAI_BASIC_AUTH=t,e):(e.TESTMUAI_API_KEY=o.access_token,e)}}return{}}catch{return{}}}var h=8e3;function d(){return g("warn: session auth may expire during long runs \u2014 if that happens, run `kane-cli login` and retry","AUTH_EXCHANGE_FAILED"),null}async function w(s,n){try{let[{getEnvironment:i},{ControllerClient:a}]=await Promise.all([import("./config-KU2UICMC.js"),import("./controller-client-OB4WD2C4.js")]),e=new a(i(s).controllerBaseUrl,n),c;try{let r=await Promise.race([e.getTmsCredentials().catch(()=>null),new Promise(o=>{c=setTimeout(()=>o(null),h)})]);if(typeof r?.username!="string"||!r.username||typeof r.access_key!="string"||!r.access_key)return d();try{let[{refreshIdentitySnapshot:o},{telemetryEnvName:t}]=await Promise.all([import("./identity-ADZ4PAJF.js"),import("./bootstrap-3LNHRDQH.js")]);await o(t(),r)}catch{}return Buffer.from(`${r.username}:${r.access_key}`,"utf8").toString("base64")}finally{clearTimeout(c)}}catch{return d()}}export{x as a,T as b,I as c,U as d,P as e};
@@ -1,4 +1,4 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{e as $e}from"./chunk-BVON52QL.js";import{a as te}from"./chunk-AROBXG66.js";import{a as K}from"./chunk-5Y2G4NC7.js";import{a as Be}from"./chunk-HKCZ67AT.js";import{a as ve}from"./chunk-SJBIXLL3.js";import{x as i}from"./chunk-DWHXXPDX.js";import{b as ye}from"./chunk-DFS4RMVP.js";import{a as k}from"./chunk-HCBYKLMW.js";import{a as s,b as o,i as Se,j as Te,k as ee}from"./chunk-C44QQJR4.js";import{a as V}from"./chunk-6YGTRKDT.js";import{e as R}from"./chunk-UR6MHSHU.js";var A=R(V(),1);var C=R(V(),1);function de(e){let t=e.flatMap(u=>[u,...u.children??[]]),n=t.filter(u=>u.status==="passed").length,l=t.filter(u=>u.status==="failed").length,a=t.filter(u=>u.status==="passed"||u.status==="failed").length;return{passed:n,failed:l,total:a}}function we(e){let t=$e(e.screenshotDispatcher,e.stepLogger,e.onReasoning,e.onStepComplete),[n,l]=(0,C.useState)(0),[a,u]=(0,C.useState)("idle"),c=(0,C.useRef)("idle"),v=(0,C.useRef)(0),S=(0,C.useRef)(!1),T=(0,C.useRef)(null),d=(0,C.useRef)(null),L=(0,C.useCallback)(h=>{c.current=h,u(h)},[]),O=(0,C.useCallback)(async h=>{let b=await e.getNextConfig(h);if(!b){L("done"),e.onAllComplete?.();return}let B=h?v.current+1:0;v.current=B,l(B),e.onStepStart?.(b,B),T.current=null,d.current=null,L("running"),await t.startRun(b,e.spawnOpts)},[t,e,L]);(0,C.useEffect)(()=>{S.current||(S.current=!0,O(null))},[]),(0,C.useEffect)(()=>{if(!t.lastRunEnd||t.lastRunEnd===T.current||c.current!=="running")return;T.current=t.lastRunEnd,c.current="transitioning",u("transitioning");let h=t.lastRunEnd,b=de(t.steps),B=t.bifurcationInfo,F={status:h.status==="passed"?"passed":"failed",duration_s:h.duration??0,reason:h.reason,runEnd:h,hadError:!1,stepsPassed:b.passed,stepsFailed:b.failed,stepsTotal:b.total,bifurcationFlows:B&&!B.isSingleFlow?B.flows:null,evidence:t.getEvidenceState()};if(!(e.onStepEnd?.(F,v.current)??!0)){L("done"),e.onAllComplete?.();return}O(F)},[t.lastRunEnd]),(0,C.useEffect)(()=>{if(!t.runError||t.runError===d.current||t.lastRunEnd||c.current!=="running")return;d.current=t.runError,c.current="transitioning",u("transitioning");let h=de(t.steps),b={status:"failed",duration_s:0,reason:t.runError,runEnd:null,hadError:!0,stepsPassed:h.passed,stepsFailed:h.failed,stepsTotal:h.total,bifurcationFlows:null,evidence:t.getEvidenceState()};if(!(e.onStepEnd?.(b,v.current)??!0)){L("done"),e.onAllComplete?.();return}O(b)},[t.runError,t.lastRunEnd]);let y=(0,C.useCallback)(()=>{t.cancelRun()},[t]);return{runner:t,currentStepIndex:n,phase:a,cancel:y}}var pe=R(V(),1);var ne=R(k(),1),Ee=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function ke({label:e,hasBifurcation:t=!1}){let[n,l]=(0,pe.useState)(0),[a,u]=(0,pe.useState)(0);K(()=>{l(v=>(v+1)%Ee.length)},80),K(()=>{u(v=>(v+1)%4)},400);let c=e??(t?"Planning approach":"Analyzing objective");return(0,ne.jsxs)(s,{marginLeft:1,children:[(0,ne.jsxs)(o,{color:i.orange,children:[Ee[n]," "]}),(0,ne.jsxs)(o,{color:i.dim,children:[c,".".repeat(a+1)]})]})}function Ie(e){if(!e.isRunning||e.replayInfo)return null;let t=e.bifurcationInfo;if(t&&!t.isSingleFlow){let n=e.steps.findIndex(a=>a.status==="running");return(n===-1?e.cmInitCounts.length===0:n>=e.cmInitCounts.length)?{label:n>0?`Planning flow ${n+1}`:void 0,hasBifurcation:!0}:null}return e.cmInitCounts.length>0||e.steps.some(n=>n.children?.length)?null:{hasBifurcation:!!t}}var I=R(V(),1);var Ce=R(V(),1);var re=R(k(),1),He="#ffc580",Ue="#ffd9a8",Le="#ffffff";function oe({text:e,active:t=!0}){let[n,l]=(0,Ce.useState)(0),a=4;if(K(()=>{l(c=>(c+1)%(e.length+a*2))},t?80:null),!t)return(0,re.jsx)(o,{color:Le,children:e});let u=e.split("").map((c,v)=>{let S=n-a,T=Math.abs(v-S-a/2),d;return T<=a/2?d=He:T<=a?d=Ue:d=Le,(0,re.jsx)(o,{color:d,children:c},v)});return(0,re.jsx)(o,{children:u})}var _=R(k(),1),We={starting:i.orange,running:i.orange,passed:i.green,failed:i.red,cancelled:i.dim,timed_out:i.orange};function ie({currentStep:e,maxSteps:t,elapsed:n,status:l}){let a=We[l]??i.orange,u=n<60?`${n.toFixed(1)}s`:`${Math.floor(n/60)}m ${Math.round(n%60)}s`;return(0,_.jsxs)(s,{marginLeft:3,children:[(0,_.jsx)(o,{color:i.dim,children:"Steps "}),(0,_.jsx)(o,{bold:!0,children:e}),(0,_.jsxs)(o,{color:i.dim,children:["/",t]}),(0,_.jsx)(o,{children:" "}),(0,_.jsx)(o,{color:i.dim,children:"Elapsed "}),(0,_.jsx)(o,{bold:!0,children:u}),(0,_.jsx)(o,{children:" "}),(0,_.jsx)(o,{color:i.dim,children:"Status "}),(0,_.jsx)(o,{bold:!0,color:a,children:l})]})}var Ve={click:"\u25CF",type:"\u229E",scroll:"\u2195",navigate:"\u2192",analyze:"\u25CE",assert:"\u25C8","if-else":"\u2442",select:"\u25BC",press_key:"\u21B5",wait:"\u2026",tool_call:"\u2299"};function Oe(e){return Ve[e]??"\u25CF"}var q=R(k(),1);function fe({steps:e,flows:t,cmInitCounts:n,renderStep:l}){return(0,q.jsxs)(s,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:[(0,q.jsxs)(o,{color:i.dim,children:["\u2501\u2501 Bifurcated into ",t?.length??e.length," flows \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"]}),e.map((a,u)=>(0,q.jsxs)(s,{flexDirection:"column",marginTop:u>0?1:0,children:[(0,q.jsxs)(o,{color:i.orange,children:["Flow ",u+1,": ",t?.[u]??a.objective]}),n&&n[u]!=null&&(0,q.jsxs)(o,{color:i.dim,children:[" \u25AA Generated task with ",n[u]," checkpoints"]}),a.children&&a.children.length>0?a.children.map(c=>{let v=!!c.branchObjective,S=`f${u}-${c.childId??"p"}-${c.index}`;return v?(0,q.jsxs)(s,{flexDirection:"column",children:[l({...c,children:void 0},S),(c.children??[]).map(T=>(0,q.jsx)(s,{marginLeft:2,children:l(T,`${S}-${T.childId??"p"}-${T.index}`)},`${S}-${T.childId??"p"}-${T.index}`))]},`${S}-host`):l(c,S)}):a.status==="pending"&&(0,q.jsx)(o,{color:i.dim,children:" \u25CB Waiting..."})]},u))]})}var H=R(k(),1);function Pe({label:e,shimmer:t=!1}){return(0,H.jsxs)(s,{marginLeft:6,children:[(0,H.jsx)(te,{}),(0,H.jsx)(o,{children:" "}),t?(0,H.jsx)(oe,{text:e,active:!0}):(0,H.jsx)(o,{color:i.dim,children:e})]})}var De=R(V(),1);var me=R(k(),1);function ze(e,t){let n=[];for(let l of e.split(`
2
+ import{e as $e}from"./chunk-Y4ODYIOP.js";import{a as te}from"./chunk-A4BDLZOD.js";import{a as K}from"./chunk-5Y2G4NC7.js";import{a as Be}from"./chunk-6DOS5CJ5.js";import{a as ve}from"./chunk-A76UL3EN.js";import{x as i}from"./chunk-DEUDRSU7.js";import{b as ye}from"./chunk-DFS4RMVP.js";import{a as k}from"./chunk-HCBYKLMW.js";import{a as s,b as o,i as Se,j as Te,k as ee}from"./chunk-C44QQJR4.js";import{a as V}from"./chunk-6YGTRKDT.js";import{e as R}from"./chunk-UR6MHSHU.js";var A=R(V(),1);var C=R(V(),1);function de(e){let t=e.flatMap(u=>[u,...u.children??[]]),n=t.filter(u=>u.status==="passed").length,l=t.filter(u=>u.status==="failed").length,a=t.filter(u=>u.status==="passed"||u.status==="failed").length;return{passed:n,failed:l,total:a}}function we(e){let t=$e(e.screenshotDispatcher,e.stepLogger,e.onReasoning,e.onStepComplete),[n,l]=(0,C.useState)(0),[a,u]=(0,C.useState)("idle"),c=(0,C.useRef)("idle"),v=(0,C.useRef)(0),S=(0,C.useRef)(!1),T=(0,C.useRef)(null),d=(0,C.useRef)(null),L=(0,C.useCallback)(h=>{c.current=h,u(h)},[]),O=(0,C.useCallback)(async h=>{let b=await e.getNextConfig(h);if(!b){L("done"),e.onAllComplete?.();return}let B=h?v.current+1:0;v.current=B,l(B),e.onStepStart?.(b,B),T.current=null,d.current=null,L("running"),await t.startRun(b,e.spawnOpts)},[t,e,L]);(0,C.useEffect)(()=>{S.current||(S.current=!0,O(null))},[]),(0,C.useEffect)(()=>{if(!t.lastRunEnd||t.lastRunEnd===T.current||c.current!=="running")return;T.current=t.lastRunEnd,c.current="transitioning",u("transitioning");let h=t.lastRunEnd,b=de(t.steps),B=t.bifurcationInfo,F={status:h.status==="passed"?"passed":"failed",duration_s:h.duration??0,reason:h.reason,runEnd:h,hadError:!1,stepsPassed:b.passed,stepsFailed:b.failed,stepsTotal:b.total,bifurcationFlows:B&&!B.isSingleFlow?B.flows:null,evidence:t.getEvidenceState()};if(!(e.onStepEnd?.(F,v.current)??!0)){L("done"),e.onAllComplete?.();return}O(F)},[t.lastRunEnd]),(0,C.useEffect)(()=>{if(!t.runError||t.runError===d.current||t.lastRunEnd||c.current!=="running")return;d.current=t.runError,c.current="transitioning",u("transitioning");let h=de(t.steps),b={status:"failed",duration_s:0,reason:t.runError,runEnd:null,hadError:!0,stepsPassed:h.passed,stepsFailed:h.failed,stepsTotal:h.total,bifurcationFlows:null,evidence:t.getEvidenceState()};if(!(e.onStepEnd?.(b,v.current)??!0)){L("done"),e.onAllComplete?.();return}O(b)},[t.runError,t.lastRunEnd]);let y=(0,C.useCallback)(()=>{t.cancelRun()},[t]);return{runner:t,currentStepIndex:n,phase:a,cancel:y}}var pe=R(V(),1);var ne=R(k(),1),Ee=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function ke({label:e,hasBifurcation:t=!1}){let[n,l]=(0,pe.useState)(0),[a,u]=(0,pe.useState)(0);K(()=>{l(v=>(v+1)%Ee.length)},80),K(()=>{u(v=>(v+1)%4)},400);let c=e??(t?"Planning approach":"Analyzing objective");return(0,ne.jsxs)(s,{marginLeft:1,children:[(0,ne.jsxs)(o,{color:i.orange,children:[Ee[n]," "]}),(0,ne.jsxs)(o,{color:i.dim,children:[c,".".repeat(a+1)]})]})}function Ie(e){if(!e.isRunning||e.replayInfo)return null;let t=e.bifurcationInfo;if(t&&!t.isSingleFlow){let n=e.steps.findIndex(a=>a.status==="running");return(n===-1?e.cmInitCounts.length===0:n>=e.cmInitCounts.length)?{label:n>0?`Planning flow ${n+1}`:void 0,hasBifurcation:!0}:null}return e.cmInitCounts.length>0||e.steps.some(n=>n.children?.length)?null:{hasBifurcation:!!t}}var I=R(V(),1);var Ce=R(V(),1);var re=R(k(),1),He="#ffc580",Ue="#ffd9a8",Le="#ffffff";function oe({text:e,active:t=!0}){let[n,l]=(0,Ce.useState)(0),a=4;if(K(()=>{l(c=>(c+1)%(e.length+a*2))},t?80:null),!t)return(0,re.jsx)(o,{color:Le,children:e});let u=e.split("").map((c,v)=>{let S=n-a,T=Math.abs(v-S-a/2),d;return T<=a/2?d=He:T<=a?d=Ue:d=Le,(0,re.jsx)(o,{color:d,children:c},v)});return(0,re.jsx)(o,{children:u})}var _=R(k(),1),We={starting:i.orange,running:i.orange,passed:i.green,failed:i.red,cancelled:i.dim,timed_out:i.orange};function ie({currentStep:e,maxSteps:t,elapsed:n,status:l}){let a=We[l]??i.orange,u=n<60?`${n.toFixed(1)}s`:`${Math.floor(n/60)}m ${Math.round(n%60)}s`;return(0,_.jsxs)(s,{marginLeft:3,children:[(0,_.jsx)(o,{color:i.dim,children:"Steps "}),(0,_.jsx)(o,{bold:!0,children:e}),(0,_.jsxs)(o,{color:i.dim,children:["/",t]}),(0,_.jsx)(o,{children:" "}),(0,_.jsx)(o,{color:i.dim,children:"Elapsed "}),(0,_.jsx)(o,{bold:!0,children:u}),(0,_.jsx)(o,{children:" "}),(0,_.jsx)(o,{color:i.dim,children:"Status "}),(0,_.jsx)(o,{bold:!0,color:a,children:l})]})}var Ve={click:"\u25CF",type:"\u229E",scroll:"\u2195",navigate:"\u2192",analyze:"\u25CE",assert:"\u25C8","if-else":"\u2442",select:"\u25BC",press_key:"\u21B5",wait:"\u2026",tool_call:"\u2299"};function Oe(e){return Ve[e]??"\u25CF"}var q=R(k(),1);function fe({steps:e,flows:t,cmInitCounts:n,renderStep:l}){return(0,q.jsxs)(s,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:[(0,q.jsxs)(o,{color:i.dim,children:["\u2501\u2501 Bifurcated into ",t?.length??e.length," flows \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"]}),e.map((a,u)=>(0,q.jsxs)(s,{flexDirection:"column",marginTop:u>0?1:0,children:[(0,q.jsxs)(o,{color:i.orange,children:["Flow ",u+1,": ",t?.[u]??a.objective]}),n&&n[u]!=null&&(0,q.jsxs)(o,{color:i.dim,children:[" \u25AA Generated task with ",n[u]," checkpoints"]}),a.children&&a.children.length>0?a.children.map(c=>{let v=!!c.branchObjective,S=`f${u}-${c.childId??"p"}-${c.index}`;return v?(0,q.jsxs)(s,{flexDirection:"column",children:[l({...c,children:void 0},S),(c.children??[]).map(T=>(0,q.jsx)(s,{marginLeft:2,children:l(T,`${S}-${T.childId??"p"}-${T.index}`)},`${S}-${T.childId??"p"}-${T.index}`))]},`${S}-host`):l(c,S)}):a.status==="pending"&&(0,q.jsx)(o,{color:i.dim,children:" \u25CB Waiting..."})]},u))]})}var H=R(k(),1);function Pe({label:e,shimmer:t=!1}){return(0,H.jsxs)(s,{marginLeft:6,children:[(0,H.jsx)(te,{}),(0,H.jsx)(o,{children:" "}),t?(0,H.jsx)(oe,{text:e,active:!0}):(0,H.jsx)(o,{color:i.dim,children:e})]})}var De=R(V(),1);var me=R(k(),1);function ze(e,t){let n=[];for(let l of e.split(`
3
3
  `)){if(l===""){n.push("");continue}let a="";for(let u of l.split(" ")){let c=u;for(;c.length>t;)a&&(n.push(a),a=""),n.push(c.slice(0,t)),c=c.slice(t);a===""?a=c:a.length+1+c.length<=t?a+=" "+c:(n.push(a),a=c)}n.push(a)}return n}function je({text:e,maxLines:t=3}){let{stdout:n}=ee(),l=Math.max(20,(n?.columns??80)-7),a=!e.trim(),[u,c]=(0,De.useState)(!0);K(()=>c(T=>!T),500);let v=(a?"Thinking\u2026":e)+(u?"\u258C":" "),S=ze(v,l).slice(-t);for(;S.length<t;)S.push("");return(0,me.jsx)(s,{borderStyle:"round",borderColor:i.muted,paddingX:1,marginLeft:3,flexDirection:"column",children:S.map((T,d)=>(0,me.jsx)(o,{color:a?i.dim:i.secondary,wrap:"truncate-end",children:T.length?T:" "},d))})}var U=R(k(),1);function se({activity:e,describe:t,describeVisible:n}){return(0,U.jsxs)(U.Fragment,{children:[e?(0,U.jsx)(Pe,{label:e.label,shimmer:e.shimmer}):null,n?(0,U.jsx)(je,{text:t??""}):null]})}var r=R(k(),1);function le(e){for(let t of e){if(t.children&&t.children.length>0){let n=le(t.children);if(n)return n}if(t.status==="running")return t}}function z(e){return e.status==="running"&&!e.branchObjective&&(!e.children||e.children.length===0)}function Fe(e){let t=[];for(let n of e)z(n)||(n.children&&n.children.length>0?t.push({...n,children:Fe(n.children)}):t.push(n));return t}function ge(e,t){if(!e)return null;let n=e.objective??"";return n.length>0&&!/^Step \d+$/.test(n)?{label:n+"\u2026",shimmer:!1}:{label:t?"Looking at the screen\u2026":"Deciding next action\u2026",shimmer:!0}}function P({step:e,indent:t=2}){let n=e.actionType?Oe(e.actionType):null,l=e.status==="running",a=e.status==="passed",u=e.status==="failed",c=e.status==="pending"||e.status==="stopped",{stdout:v}=ee(),S=v?.columns??80,T=Math.max(20,S-t-21),d=e.objective??"",L=d.length>T?d.slice(0,T-1)+"\u2026":d,O=(e.duration??0)*1e3,y=e.duration!=null?O<1e3?`${Math.round(O)}ms`:`${(O/1e3).toFixed(1)}s`:"";return(0,r.jsxs)(s,{flexDirection:"column",children:[(0,r.jsxs)(s,{marginLeft:t,children:[(0,r.jsx)(s,{width:4,children:(0,r.jsxs)(o,{color:i.muted,children:[String(e.index).padStart(2," ")," "]})}),(0,r.jsx)(s,{width:3,children:l?(0,r.jsx)(te,{}):a?(0,r.jsx)(o,{color:i.green,bold:!0,children:"\u2713"}):u?(0,r.jsx)(o,{color:i.red,bold:!0,children:"\u2717"}):(0,r.jsx)(o,{color:i.muted,children:"\u25CB"})}),(0,r.jsx)(s,{flexGrow:1,children:l?(0,r.jsx)(oe,{text:L,active:!0}):u?(0,r.jsx)(o,{color:i.red,children:L}):c?(0,r.jsx)(o,{color:i.dim,children:L}):(0,r.jsx)(o,{color:i.dim,children:L})}),(a||u)&&n?(0,r.jsx)(s,{width:3,marginLeft:1,children:(0,r.jsx)(o,{color:i.muted,children:n})}):(0,r.jsx)(s,{width:3,marginLeft:1}),(0,r.jsx)(s,{width:7,justifyContent:"flex-end",children:(0,r.jsx)(o,{color:i.dim,children:y})})]}),e.children&&e.children.length>0&&(0,r.jsx)(s,{flexDirection:"column",children:e.children.map((h,b)=>(0,r.jsx)(P,{step:h,indent:t+2},`child-${b}`))})]})}function Xe(e){return e.type==="cm_init"?(0,r.jsx)(s,{marginLeft:2,paddingLeft:1,children:(0,r.jsxs)(o,{color:i.dim,children:["\u25AA Generated task with ",e.count," checkpoints"]})}):(0,r.jsx)(s,{marginLeft:2,paddingLeft:1,children:(0,r.jsx)(P,{step:e.step})})}function _e({steps:e,bifurcated:t,flows:n,cmInitCounts:l,maxSteps:a=50,staticSteps:u=!1,onStepCommit:c,describe:v,describeVisible:S,describeRevealing:T}){let d=(0,I.useRef)(new Set),L=(0,I.useRef)(!1),O=(0,I.useRef)(new Set),y=(0,I.useRef)(!1),h=(0,I.useRef)(new Set),b=(0,I.useRef)(0);(0,I.useEffect)(()=>{e.length===0&&b.current>0&&(d.current.clear(),L.current=!1,O.current.clear(),y.current=!1,h.current.clear()),b.current=e.length},[e.length]);let B=e.flatMap(p=>[p,...p.children??[]]),F=B.some(p=>p.status==="running"),M=B.some(p=>p.status==="failed"),X=B.length===0||B.every(p=>p.status==="pending"),Y=B.filter(p=>p.status==="passed"||p.status==="failed").length,N;X?N="starting":F?N="running":M?N="failed":N="passed";let J=(0,I.useRef)(null),[ce,he]=(0,I.useState)(0);(0,I.useEffect)(()=>{B.length===0||X?(J.current=null,he(0)):F&&J.current==null&&(J.current=Date.now())},[F,X,B.length]),(0,I.useEffect)(()=>{if(!F)return;let p=setInterval(()=>{J.current!=null&&he((Date.now()-J.current)/1e3)},500);return()=>clearInterval(p)},[F]);let ae=(0,I.useRef)(new Set),[,xe]=(0,I.useState)(0),be=(0,I.useRef)(!1);(0,I.useEffect)(()=>{if(!c||!u||t)return;let p=[];!be.current&&l&&l[0]!=null&&(be.current=!0,l[0]>0&&p.push({key:"cm_init_0",type:"cm_init",count:l[0]}));for(let g of e)(g.status==="passed"||g.status==="failed")&&!ae.current.has(g.index)&&(ae.current.add(g.index),p.push({key:`step_${g.index}`,type:"step",step:{...g,children:g.children?[...g.children]:void 0}}));if(p.length>0){for(let g of p)c(Xe(g));xe(g=>g+1)}},[e,t,l,u,c]),(0,I.useEffect)(()=>{if(!c||u)return;let p=d.current.size;if(!t&&!y.current&&l&&l[0]!=null&&(y.current=!0,l[0]>0&&c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsxs)(o,{color:i.dim,children:["\u25A0 Generated task with ",l[0]," checkpoints"]})}))),t&&n&&!L.current&&(L.current=!0,c((0,r.jsx)(o,{color:i.purple,children:"\u2501\u2501 Bifurcated into "+n.length+" flows \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"}))),t){let g=e.flatMap((x,f)=>{let m=x.children??[];return!O.current.has(f)&&m.length>0&&(O.current.add(f),c((0,r.jsx)(o,{color:i.purple,children:" Flow "+(f+1)+": "+(n?.[f]??"")})),l?.[f]!=null&&l[f]>0&&!h.current.has(f)&&(h.current.add(f),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsxs)(o,{color:i.dim,children:[" \u25AA Generated task with ",l[f]," checkpoints"]})})))),l?.[f]!=null&&l[f]>0&&O.current.has(f)&&!h.current.has(f)&&(h.current.add(f),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsxs)(o,{color:i.dim,children:[" \u25AA Generated task with ",l[f]," checkpoints"]})}))),m});for(let x of g){let f=`${x.childId??"p"}-${x.index}-${x.objective}`;if(!!x.branchObjective){d.current.has(f)||(d.current.add(f),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(P,{step:{...x,children:void 0}})})));for(let $ of x.children??[]){let w=`child-${x.childId??"p"}-${x.index}-${$.childId??"p"}-${$.index}-${$.objective}`;d.current.has(w)||($.status==="passed"||$.status==="failed"||$.status==="stopped")&&(d.current.add(w),c((0,r.jsx)(s,{marginLeft:4,children:(0,r.jsx)(P,{step:$})})))}continue}d.current.has(f)||(x.status==="passed"||x.status==="failed"||x.status==="stopped")&&(d.current.add(f),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(P,{step:x})})))}}else for(let g of e){let x=`${g.index}-${g.objective}`,f=!!g.branchObjective;f&&!d.current.has(x)&&(d.current.add(x),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(P,{step:{...g,children:void 0}})})));for(let m of g.children??[]){let $=`child-${g.index}-${m.childId??"p"}-${m.index}-${m.objective}`;d.current.has($)||(m.status==="passed"||m.status==="failed"||m.status==="stopped")&&(d.current.add($),c((0,r.jsx)(s,{marginLeft:4,children:(0,r.jsx)(P,{step:m})})))}!f&&!d.current.has(x)&&(g.status==="passed"||g.status==="failed"||g.status==="stopped")&&(d.current.add(x),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(P,{step:{...g,children:void 0}})})))}d.current.size>p&&xe(g=>g+1)},[e,c,t,n,l]);let G=[];if(u&&!t)for(let p of e)ae.current.has(p.index)||G.push(p);else if(c&&!u)if(t)for(let p of e){let g=p.children??[],x=[];for(let f of g){let m=`${f.childId??"p"}-${f.index}-${f.objective}`,$=d.current.has(m);if(f.branchObjective){let w=(f.children??[]).filter(Q=>{let ue=`child-${f.childId??"p"}-${f.index}-${Q.childId??"p"}-${Q.index}-${Q.objective}`;return!d.current.has(ue)});(!$||w.length>0)&&x.push({...f,children:w})}else $||x.push(f)}x.length>0&&G.push({...p,children:x})}else for(let p of e){let g=`${p.index}-${p.objective}`,x=d.current.has(g),f=(p.children??[]).filter(m=>{let $=`child-${p.index}-${m.childId??"p"}-${m.index}-${m.objective}`;return!d.current.has($)});x?f.length>0&&G.push({...p,children:f}):G.push({...p,children:f})}if(!u){let p=c?G:e,g=le(p),x=ge(g,T);return(0,r.jsxs)(s,{flexDirection:"column",children:[t?c?p.length>0?(0,r.jsx)(s,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:p.map((m,$)=>(0,r.jsx)(s,{flexDirection:"column",marginTop:$>0?1:0,children:m.children&&m.children.length>0?m.children.map(w=>{if(z(w))return null;let Q=!!w.branchObjective,ue=`${w.childId??"p"}-${w.index}-${w.objective}`,Ke=d.current.has(ue);return Q?(0,r.jsxs)(s,{flexDirection:"column",children:[!Ke&&(0,r.jsx)(P,{step:{...w,children:void 0}}),(w.children??[]).filter(Z=>!z(Z)).map(Z=>(0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(P,{step:Z})},`f${$}-${w.index}-${Z.childId??"p"}-${Z.index}`))]},`f${$}-host-${w.childId??"p"}-${w.index}`):(0,r.jsx)(P,{step:w},`f${$}-${w.childId??"p"}-${w.index}`)}):m.status==="pending"&&(0,r.jsx)(o,{color:i.dim,children:" \u25CB Waiting..."})},$))}):null:(0,r.jsx)(fe,{steps:e,flows:n,cmInitCounts:l,renderStep:(m,$)=>z(m)?null:(0,r.jsx)(P,{step:m},$)}):(0,r.jsxs)(s,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:[!c&&l&&l[0]!=null&&(0,r.jsxs)(o,{color:i.dim,children:["\u25AA Generated task with ",l[0]," checkpoints"]}),p.filter(m=>!(m.status==="running"&&(!m.children||m.children.length===0))).map(m=>{let $=`${m.index}-${m.objective}`;return c&&d.current.has($)?(0,r.jsx)(s,{flexDirection:"column",children:(m.children??[]).filter(w=>!z(w)).map(w=>(0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(P,{step:w})},`${w.childId??"p"}-${w.index}`))},`branch-children-${m.index}`):(0,r.jsx)(P,{step:m},m.index)})]}),(0,r.jsx)(se,{activity:x,describe:v,describeVisible:S}),B.length>0&&(0,r.jsx)(ie,{currentStep:Y,maxSteps:a,elapsed:ce,status:N})]})}if(t){let p=le(e),g=ge(p,T);return(0,r.jsxs)(s,{flexDirection:"column",children:[(0,r.jsx)(fe,{steps:e,flows:n,cmInitCounts:l,renderStep:(x,f)=>z(x)?null:(0,r.jsx)(P,{step:x},f)}),(0,r.jsx)(se,{activity:g,describe:v,describeVisible:S}),B.length>0&&(0,r.jsx)(ie,{currentStep:Y,maxSteps:a,elapsed:ce,status:N})]})}let Ne=le(G),Ge=ge(Ne,T),Re=Fe(G);return(0,r.jsxs)(s,{flexDirection:"column",children:[Re.length>0&&(0,r.jsx)(s,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:Re.map(p=>(0,r.jsx)(P,{step:p},p.index))}),(0,r.jsx)(se,{activity:Ge,describe:v,describeVisible:S}),B.length>0&&(0,r.jsx)(ie,{currentStep:Y,maxSteps:a,elapsed:ce,status:N})]})}var W=R(k(),1);function Ae({runner:e,runKey:t,onStepCommit:n}){let l=Ie({isRunning:e.isRunning,bifurcationInfo:e.bifurcationInfo,steps:e.steps,cmInitCounts:e.cmInitCounts,replayInfo:e.replayInfo});return(0,W.jsxs)(W.Fragment,{children:[l&&(0,W.jsx)(ke,{label:l.label,hasBifurcation:l.hasBifurcation}),e.isRunning&&e.steps.length>0&&(0,W.jsx)(_e,{steps:e.steps,bifurcated:!!e.bifurcationInfo&&!e.bifurcationInfo.isSingleFlow,flows:e.bifurcationInfo?.flows,cmInitCounts:e.cmInitCounts,maxSteps:e.maxSteps,onStepCommit:n},`run-${t}`)]})}var D=R(k(),1),Ye=64;function Je(e){return e.split(`
4
4
  `).map(t=>t.replace(/^[-–•]\s*/,"").trim()).filter(t=>t.length>0)}function qe({status:e,summary:t,duration:n,steps:l,stepsPassed:a,stepsFailed:u,reason:c,creditsConsumed:v}){let S=e==="passed",T=S?i.green:i.red,d=S?"\u2713":"\u2717",L=e.toUpperCase(),O=a??(S?l:Math.max(0,l-1)),y=u??(S?0:1),h=y>0?`${l} steps (${O} passed, ${y} failed)`:`${l} steps`,b=n<60?`${n.toFixed(1)}s`:`${Math.floor(n/60)}m ${Math.round(n%60)}s`,B=Je(t);return(0,D.jsx)(s,{flexDirection:"column",marginTop:1,children:(0,D.jsxs)(s,{borderStyle:"round",borderColor:T,flexDirection:"column",paddingX:2,paddingY:1,width:Ye+6,children:[(0,D.jsxs)(s,{flexDirection:"column",children:[(0,D.jsxs)(o,{bold:!0,color:T,children:[d," ",L]}),(0,D.jsxs)(o,{color:i.dim,wrap:"wrap",children:[h," \xB7 ",b,typeof v=="number"&&v>0?` \xB7 ${parseFloat(v.toFixed(4))} credits`:""]})]}),B.length>0&&(0,D.jsx)(s,{flexDirection:"column",marginTop:1,marginLeft:1,children:B.map((F,M)=>(0,D.jsxs)(s,{marginBottom:M<B.length-1?1:0,children:[(0,D.jsx)(o,{color:i.orange,children:"\u25CF "}),(0,D.jsx)(s,{flexShrink:1,children:(0,D.jsx)(o,{wrap:"wrap",children:F})})]},M))}),c&&!S&&(0,D.jsx)(s,{marginTop:1,children:(0,D.jsxs)(o,{color:i.red,wrap:"wrap",children:["Reason: ",c]})})]})})}var j=R(k(),1);function Me({message:e,code:t,remediation:n,docsUrl:l}){return(0,j.jsx)(ve,{title:"Error",variant:"error",children:(0,j.jsxs)(s,{flexDirection:"column",paddingY:1,children:[(0,j.jsxs)(o,{color:i.red,bold:!0,children:[" \u2717 ",e]}),t&&(0,j.jsxs)(s,{marginTop:0,marginLeft:5,children:[(0,j.jsx)(o,{color:i.muted,children:"Code: "}),(0,j.jsx)(o,{color:i.dim,children:t})]}),n&&(0,j.jsxs)(s,{flexDirection:"column",marginTop:1,marginLeft:5,children:[(0,j.jsx)(o,{color:i.green,bold:!0,children:"Fix:"}),(0,j.jsxs)(o,{color:i.orange,children:["$ ",n]})]}),l&&(0,j.jsxs)(s,{marginTop:1,marginLeft:5,children:[(0,j.jsx)(o,{color:i.muted,children:"Docs: "}),(0,j.jsx)(o,{color:i.orange,underline:!0,children:l})]})]})})}var E=R(k(),1);function un(e){let{exit:t}=Te(),{append:n}=ye(),l=(0,A.useRef)(!1);(0,A.useEffect)(()=>{l.current||(l.current=!0,n((0,E.jsx)(s,{flexDirection:"column",marginBottom:1,children:(0,E.jsxs)(s,{borderStyle:"round",borderColor:"#dc4e08",paddingX:2,children:[(0,E.jsx)(o,{color:"#ff9500",bold:!0,children:"KaneAI CLI"}),(0,E.jsx)(o,{color:i.dim,children:" \u2502 "}),(0,E.jsx)(o,{color:i.orange,children:e.topBanner.model}),(0,E.jsx)(o,{color:i.dim,children:" \u2502 "}),(0,E.jsx)(o,{color:i.dim,children:e.topBanner.auth})]})})),n((0,E.jsx)(Qe,{data:e.globalConfig})),e.priorAttemptRollup&&n((0,E.jsx)(o,{color:i.dim,children:` \u21B3 replayed ${e.priorAttemptRollup.startIdx}..${e.priorAttemptRollup.endIdx-1} (${e.priorAttemptRollup.count} steps, from prior attempt)`})))},[]);let a=(0,A.useRef)(null),u=(0,A.useCallback)(async y=>{let h=await e.getNextStep(y);return h?(a.current=h,h.config):(a.current=null,null)},[e]),c=(0,A.useCallback)((y,h)=>{let b=a.current;if(!b)return;let B=b.mode==="replay"?"cyan":"#dc4e08",F=b.modeReason?` (${b.modeReason})`:"",M=b.perStepOverrides?Object.entries(b.perStepOverrides):[];n((0,E.jsxs)(s,{flexDirection:"column",marginBottom:0,children:[(0,E.jsxs)(o,{children:[(0,E.jsxs)(o,{color:i.dim,children:[b.banner.stepLabel," "]}),(0,E.jsxs)(o,{color:B,children:["[",b.mode,"]"]}),(0,E.jsx)(o,{color:i.dim,children:F})]}),(0,E.jsx)(o,{color:i.dim,children:b.banner.objective}),M.length>0&&(0,E.jsxs)(o,{color:i.dim,children:["overrides: ",M.map(([X,Y])=>`${X}=${Y}`).join(", ")]})]}))},[n]),v=(0,A.useRef)(0),S=(0,A.useRef)(!1),T=(0,A.useCallback)((y,h)=>(y.hadError?n((0,E.jsx)(Me,{message:y.reason??"Runner error",code:"RUNNER_ERROR"})):n((0,E.jsx)(s,{flexDirection:"column",marginBottom:1,children:(0,E.jsx)(qe,{status:y.status,summary:y.runEnd?.summary??"",duration:y.runEnd?.duration??0,steps:y.stepsTotal,stepsPassed:y.stepsPassed,stepsFailed:y.stepsFailed,reason:y.runEnd?.reason,creditsConsumed:y.runEnd?.credits_consumed})})),e.onStepEnd?.(y,h)??!0),[n,e]),d=we({getNextConfig:u,onStepStart:c,onStepEnd:T,onAllComplete:()=>{e.onAllComplete(),e.exitOnComplete!==!1&&setImmediate(()=>t())},screenshotDispatcher:e.screenshotDispatcher,stepLogger:e.stepLogger,onReasoning:e.onReasoning,onStepComplete:e.onStepComplete,spawnOpts:e.spawnOpts}),L=250,O=5e3;return Se((y,h)=>{if(h.ctrl&&y==="c"){let b=Date.now(),B=b-v.current;if(B<L)return;S.current&&B<O?(d.cancel(),e.onCancel?.(),e.exitOnComplete!==!1&&setImmediate(()=>t())):(S.current=!0,n((0,E.jsx)(o,{color:"yellow",children:"press Ctrl+C again to cancel run"}))),v.current=b}}),(0,E.jsx)(s,{flexDirection:"column",children:d.phase!=="done"&&(0,E.jsx)(Ae,{runner:d.runner,runKey:d.currentStepIndex,onStepCommit:n})})}function Qe({data:e}){return(0,E.jsx)(Be,{title:"test.md run",titleColor:"#ff9500",borderColor:i.dim,rows:[{label:"source",value:e.source},{label:"steps",value:`${e.steps.total} (${e.steps.replay} replay, ${e.steps.author} author per walker)`},{label:"model",value:e.model},{label:"viewport",value:`${e.viewport.width} x ${e.viewport.height}`},{label:"chrome",value:e.chrome},{label:"session",value:e.session},{label:"variables",value:`${e.variables.count} (${e.variables.secrets} secret)`},{label:"flags",value:e.flags.length>0?e.flags.join(" "):"(none)"}]})}export{_e as a,ke as b,Ie as c,de as d,qe as e,Me as f,un as g};
@@ -1,3 +1,3 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as w,b as O}from"./chunk-4PMZ5FCD.js";import{a as I}from"./chunk-KBM3XHAM.js";import{e as L}from"./chunk-IDX3TOPY.js";import{a as N,b as k}from"./chunk-BKM2LWU2.js";import{a as R,b as y,c as T,d as m,e as A,g as b,h as r}from"./chunk-RSSOJ3L2.js";import{b as x}from"./chunk-5EOX4MEY.js";import{a as E}from"./chunk-RZ4F3BHX.js";import{a as g,i as v}from"./chunk-DWHXXPDX.js";import{platform as X,arch as Y}from"os";import P from"fs";import M from"fs";import D from"path";var V=1e3,d=0,j=new Set([130,3]),a=class t{ids;logger;opts;ended=!1;createdAt=Date.now();errorState;constructor(e,n={emitted:!1}){this.ids=e.envelope,this.logger=e.logger,this.opts=e,this.errorState=n}get enabled(){return this.logger!==null}event(e,n={}){if(!this.logger)return;e==="ASR_ERROR"&&(this.errorState.emitted=!0);let i=m(this.ids,e,n);this.logger.log(R[e],e,e,C(i))}error(e,n={}){this.logger&&(this.logger.escalate(d),this.event("ASR_ERROR",{...n,error_code:e}))}child(e,n){return new t({...this.opts,envelope:{...this.ids,operation_id:n,parent_operation_id:this.ids.operation_id,verb:"design"}},this.errorState)}async lateBindContext(e){if(!(!this.logger||this.ids.context_instance_id))try{let{ensureStoreIds:n}=await import("./store-id-EOSGEKVK.js"),{ids:i,cloned:s}=n(e);this.ids.context_lineage_id=i.context_lineage_id,this.ids.context_instance_id=i.context_instance_id,s&&this.event("ASR_CONTEXT_CLONED")}catch{}}agentSession(e){this.ids.agent_session_id=e}spawnEnv(){if(!this.opts.telemetryEnabled)return{};let e={TESTMUAI_USER_SESSION_ID:this.ids.session_id,TESTMUAI_OPERATION_ID:this.ids.operation_id,TESTMUAI_CLIENT_VERSION:this.opts.clientVersion,TESTMUAI_TELEMETRY_PROXY_URL:this.opts.proxyUrl};return this.ids.context_instance_id&&(e.TESTMUAI_CONTEXT_INSTANCE_ID=this.ids.context_instance_id),e}traceTee(){return e=>{if(!this.logger)return;let n=typeof e.kind=="string"?e.kind.slice(0,64):"trace",i={...C(m(this.ids,"ASR_CMD_START",{})),trace_kind:n};typeof e.code=="string"&&(i.trace_code=e.code.slice(0,64)),delete i.event,this.logger.logStep(d,`trace_${n}`,n,i)}}wireTrace(e,n,i){if(!this.logger)return;i&&this.agentSession(i);let s=n&&typeof n=="object"?n:{};switch(e){case"spawn":this.event("ASR_AGENT_SPAWN",{tier:s.tier});break;case"session_paused":this.event("ASR_SESSION_PAUSED",s);break;case"commit":this.event("ASR_COMMIT",s);break;default:this.traceTee()({kind:e,code:typeof s.code=="string"?s.code:void 0})}}banner(){return`session: ${this.ids.session_id}`}supportFooter(){return`if this keeps failing, share this id with support: ${this.ids.session_id}`}async end(e){if(!this.ended){if(this.ended=!0,e.duration_ms===void 0&&(e={...e,duration_ms:Date.now()-this.createdAt}),this.logger)if(e.exit_code===0?this.logger.discardSteps(d):this.logger.escalate(d),e.exit_code>0&&!j.has(e.exit_code)&&!this.errorState.emitted&&this.event("ASR_ERROR",{error_code:e.exit_code===2?"usage_exit_unattributed":`exit_${e.exit_code}_unattributed`,exit_code:e.exit_code}),this.event("ASR_CMD_END",e),this.opts.longSession)await this.logger.shutdown();else{let n=await this.logger.flushOnce(V);(n==="failed"||n==="timeout")&&A(this.logger.drainBuffer())}this.logger&&this.writeManifestLine(e.exit_code),r(null)}}writeManifestLine(e){try{let n=x(this.ids.context_instance_id??null);M.mkdirSync(D.dirname(n),{recursive:!0});let i={ts:new Date().toISOString(),session_id:this.ids.session_id,operation_id:this.ids.operation_id,agent_session_id:this.ids.agent_session_id,verb:this.ids.verb,mode:this.ids.mode,exit_code:e};M.appendFileSync(n,JSON.stringify(i)+`
2
+ import{a as w,b as O}from"./chunk-4PMZ5FCD.js";import{a as I}from"./chunk-KBM3XHAM.js";import{e as L}from"./chunk-IDX3TOPY.js";import{a as N,b as k}from"./chunk-BKM2LWU2.js";import{a as R,b as y,c as T,d as m,e as A,g as b,h as r}from"./chunk-RSSOJ3L2.js";import{b as x}from"./chunk-5EOX4MEY.js";import{a as E}from"./chunk-RZ4F3BHX.js";import{a as g,i as v}from"./chunk-DEUDRSU7.js";import{platform as X,arch as Y}from"os";import P from"fs";import M from"fs";import D from"path";var V=1e3,d=0,j=new Set([130,3]),a=class t{ids;logger;opts;ended=!1;createdAt=Date.now();errorState;constructor(e,n={emitted:!1}){this.ids=e.envelope,this.logger=e.logger,this.opts=e,this.errorState=n}get enabled(){return this.logger!==null}event(e,n={}){if(!this.logger)return;e==="ASR_ERROR"&&(this.errorState.emitted=!0);let i=m(this.ids,e,n);this.logger.log(R[e],e,e,C(i))}error(e,n={}){this.logger&&(this.logger.escalate(d),this.event("ASR_ERROR",{...n,error_code:e}))}child(e,n){return new t({...this.opts,envelope:{...this.ids,operation_id:n,parent_operation_id:this.ids.operation_id,verb:"design"}},this.errorState)}async lateBindContext(e){if(!(!this.logger||this.ids.context_instance_id))try{let{ensureStoreIds:n}=await import("./store-id-EOSGEKVK.js"),{ids:i,cloned:s}=n(e);this.ids.context_lineage_id=i.context_lineage_id,this.ids.context_instance_id=i.context_instance_id,s&&this.event("ASR_CONTEXT_CLONED")}catch{}}agentSession(e){this.ids.agent_session_id=e}spawnEnv(){if(!this.opts.telemetryEnabled)return{};let e={TESTMUAI_USER_SESSION_ID:this.ids.session_id,TESTMUAI_OPERATION_ID:this.ids.operation_id,TESTMUAI_CLIENT_VERSION:this.opts.clientVersion,TESTMUAI_TELEMETRY_PROXY_URL:this.opts.proxyUrl};return this.ids.context_instance_id&&(e.TESTMUAI_CONTEXT_INSTANCE_ID=this.ids.context_instance_id),e}traceTee(){return e=>{if(!this.logger)return;let n=typeof e.kind=="string"?e.kind.slice(0,64):"trace",i={...C(m(this.ids,"ASR_CMD_START",{})),trace_kind:n};typeof e.code=="string"&&(i.trace_code=e.code.slice(0,64)),delete i.event,this.logger.logStep(d,`trace_${n}`,n,i)}}wireTrace(e,n,i){if(!this.logger)return;i&&this.agentSession(i);let s=n&&typeof n=="object"?n:{};switch(e){case"spawn":this.event("ASR_AGENT_SPAWN",{tier:s.tier});break;case"session_paused":this.event("ASR_SESSION_PAUSED",s);break;case"commit":this.event("ASR_COMMIT",s);break;default:this.traceTee()({kind:e,code:typeof s.code=="string"?s.code:void 0})}}banner(){return`session: ${this.ids.session_id}`}supportFooter(){return`if this keeps failing, share this id with support: ${this.ids.session_id}`}async end(e){if(!this.ended){if(this.ended=!0,e.duration_ms===void 0&&(e={...e,duration_ms:Date.now()-this.createdAt}),this.logger)if(e.exit_code===0?this.logger.discardSteps(d):this.logger.escalate(d),e.exit_code>0&&!j.has(e.exit_code)&&!this.errorState.emitted&&this.event("ASR_ERROR",{error_code:e.exit_code===2?"usage_exit_unattributed":`exit_${e.exit_code}_unattributed`,exit_code:e.exit_code}),this.event("ASR_CMD_END",e),this.opts.longSession)await this.logger.shutdown();else{let n=await this.logger.flushOnce(V);(n==="failed"||n==="timeout")&&A(this.logger.drainBuffer())}this.logger&&this.writeManifestLine(e.exit_code),r(null)}}writeManifestLine(e){try{let n=x(this.ids.context_instance_id??null);M.mkdirSync(D.dirname(n),{recursive:!0});let i={ts:new Date().toISOString(),session_id:this.ids.session_id,operation_id:this.ids.operation_id,agent_session_id:this.ids.agent_session_id,verb:this.ids.verb,mode:this.ids.mode,exit_code:e};M.appendFileSync(n,JSON.stringify(i)+`
3
3
  `,{flag:"a",mode:384})}catch{}}};function C(t){let e={event:t.event,session_id:t.session_id,operation_id:t.operation_id,verb:t.verb,mode:t.mode,component:t.component,seq:t.seq,context_lineage_id:t.context_lineage_id,context_instance_id:t.context_instance_id};t.parent_operation_id&&(e.parent_operation_id=t.parent_operation_id),t.agent_session_id&&(e.agent_session_id=t.agent_session_id);for(let[n,i]of Object.entries(t.context))e[n]=i;return e}var u=process.env.KANE_TELEMETRY_URL||v;function B(){return process.env.TESTMUAI_BASE_URL?"custom":process.env.TESTMUAI_ENV==="stage"?"stage":"prod"}function _e(t){let e=process.env.KANE_TELEMETRY!=="0"&&(!process.env.VITEST||process.env.KANE_TELEMETRY==="1"),n=t.env??B(),i=null;if(t.resumeSid&&t.contextRoot)try{let o=L(t.contextRoot,t.resumeSid);o?.user_session_id&&(i=o.user_session_id)}catch{}if(!i&&t.applyPlanPath)try{let o=JSON.parse(P.readFileSync(t.applyPlanPath,"utf8"));o.telemetry?.user_session_id&&(i=o.telemetry.user_session_id)}catch{}let s=i!==null;i||(i=y());let l=null,c=null,f=!1;if(t.contextRoot&&P.existsSync(t.contextRoot))if(t.write&&e){let o=k(t.contextRoot);l=o.ids.context_lineage_id,c=o.ids.context_instance_id,f=o.cloned}else{let o=N(t.contextRoot);l=o?.context_lineage_id??null,c=o?.context_instance_id??null}let h={session_id:i,operation_id:T(),context_lineage_id:l,context_instance_id:c,verb:t.verb,mode:t.mode,component:"kane-cli"},_=null;if(e){let o=I(n),S={org_id:o.org_id??"",user_id:o.user_id??"",machine_id:o.machine_id,email:null,email_domain:"",user_type:o.user_type??"unknown",env:o.env,plan:o.plan??"unknown"},U=t.mode==="interactive"||t.mode==="cli"?"cli":"agent";_=new w({proxyUrl:u,sessionId:i,identity:S,device:{cli_version:g,platform:X(),arch:Y(),host_agent:O(),invocation_mode:U},getToken:async()=>null}),t.longSession&&_.start()}let p=new a({envelope:h,logger:_,longSession:!!t.longSession,proxyUrl:u,clientVersion:`kane-cli/${g}`,telemetryEnabled:e});return e&&(r(h),p.event("ASR_CMD_START",{resumed:s,applied_plan:!!t.applyPlanPath}),f&&p.event("ASR_CONTEXT_CLONED"),b(async o=>{try{return(await E(u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)})).ok}catch{return!1}}).catch(()=>{})),p}export{B as a,_e as b};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as b}from"./chunk-7RAIRUXO.js";import{m as d,x as o}from"./chunk-DWHXXPDX.js";import{a as L}from"./chunk-HCBYKLMW.js";import{a as u,b as c,i as A}from"./chunk-C44QQJR4.js";import{a as D}from"./chunk-6YGTRKDT.js";import{e as h}from"./chunk-UR6MHSHU.js";var x=h(D(),1);import{readdirSync as N,mkdirSync as B,statSync as k}from"fs";import{join as P}from"path";var r=h(L(),1);function O(n){try{return N(n).filter(l=>{try{return k(P(n,l)).isDirectory()}catch{return!1}})}catch{return[]}}function E(n,l,f,v){return{name:n,path:l,label:n,isActive:v}}function H({currentPath:n,onSelect:l,onCancel:f}){let s=O(d).map(i=>{let e=P(d,i);return E(i,e,n,e===n)}),p=!n,R=s.length+2,[a,C]=(0,x.useState)(()=>{if(p)return 0;let i=s.findIndex(e=>e.isActive);return i>=0?i+1:0}),[T,I]=(0,x.useState)(!1),[S,g]=(0,x.useState)("");return A((i,e)=>{if(T){if(e.escape){I(!1),g("");return}if(e.return){let t=S.trim();if(t){let m=P(d,t);B(m,{recursive:!0}),l(m),f()}return}if(e.backspace||e.delete){g(t=>t.slice(0,-1));return}i&&!e.ctrl&&!e.meta&&g(t=>t+i);return}if(e.escape){f();return}if(e.upArrow){C(t=>Math.max(0,t-1));return}if(e.downArrow){C(t=>Math.min(R-1,t+1));return}if(e.return){if(a===0){p||l(""),f();return}if(a===s.length+1){B(d,{recursive:!0}),I(!0),g("");return}let t=s[a-1];t&&!t.isActive&&l(t.path),f();return}}),T?(0,r.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,r.jsx)(c,{color:o.orange,bold:!0,children:"Chrome Profile \u203A New"}),(0,r.jsxs)(u,{marginTop:1,children:[(0,r.jsx)(c,{color:o.secondary,children:"Name: "}),(0,r.jsx)(c,{children:S}),(0,r.jsx)(c,{color:o.dim,children:"\u2588"})]}),(0,r.jsx)(b,{bindings:[{keys:"\u21B5",label:"create"}],escBackLabel:"back"})]}):(0,r.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,r.jsx)(c,{color:o.orange,bold:!0,children:"Chrome Profile"}),(0,r.jsxs)(u,{flexDirection:"column",marginTop:1,children:[(0,r.jsxs)(c,{color:p?o.green:a===0?o.orange:o.dim,children:[a===0?"\u276F ":" ","Use temporary (no profile)",p?" \u25CF active":""]}),s.map((i,e)=>{let m=e+1===a,w=m?"\u276F ":" ",y=i.isActive?o.green:m?o.orange:void 0;return(0,r.jsxs)(c,{color:y,children:[w,i.label,i.isActive?" \u25CF active":""]},i.name)}),(0,r.jsxs)(c,{color:a===s.length+1?o.orange:o.dim,children:[a===s.length+1?"\u276F ":" ","+ Create new"]})]}),(0,r.jsx)(b,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"select"}],escBackLabel:"back"})]})}export{O as a,E as b,H as c};
2
+ import{a as b}from"./chunk-5NBT5IVT.js";import{m as d,x as o}from"./chunk-DEUDRSU7.js";import{a as L}from"./chunk-HCBYKLMW.js";import{a as u,b as c,i as A}from"./chunk-C44QQJR4.js";import{a as D}from"./chunk-6YGTRKDT.js";import{e as h}from"./chunk-UR6MHSHU.js";var x=h(D(),1);import{readdirSync as N,mkdirSync as B,statSync as k}from"fs";import{join as P}from"path";var r=h(L(),1);function O(n){try{return N(n).filter(l=>{try{return k(P(n,l)).isDirectory()}catch{return!1}})}catch{return[]}}function E(n,l,f,v){return{name:n,path:l,label:n,isActive:v}}function H({currentPath:n,onSelect:l,onCancel:f}){let s=O(d).map(i=>{let e=P(d,i);return E(i,e,n,e===n)}),p=!n,R=s.length+2,[a,C]=(0,x.useState)(()=>{if(p)return 0;let i=s.findIndex(e=>e.isActive);return i>=0?i+1:0}),[T,I]=(0,x.useState)(!1),[S,g]=(0,x.useState)("");return A((i,e)=>{if(T){if(e.escape){I(!1),g("");return}if(e.return){let t=S.trim();if(t){let m=P(d,t);B(m,{recursive:!0}),l(m),f()}return}if(e.backspace||e.delete){g(t=>t.slice(0,-1));return}i&&!e.ctrl&&!e.meta&&g(t=>t+i);return}if(e.escape){f();return}if(e.upArrow){C(t=>Math.max(0,t-1));return}if(e.downArrow){C(t=>Math.min(R-1,t+1));return}if(e.return){if(a===0){p||l(""),f();return}if(a===s.length+1){B(d,{recursive:!0}),I(!0),g("");return}let t=s[a-1];t&&!t.isActive&&l(t.path),f();return}}),T?(0,r.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,r.jsx)(c,{color:o.orange,bold:!0,children:"Chrome Profile \u203A New"}),(0,r.jsxs)(u,{marginTop:1,children:[(0,r.jsx)(c,{color:o.secondary,children:"Name: "}),(0,r.jsx)(c,{children:S}),(0,r.jsx)(c,{color:o.dim,children:"\u2588"})]}),(0,r.jsx)(b,{bindings:[{keys:"\u21B5",label:"create"}],escBackLabel:"back"})]}):(0,r.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,r.jsx)(c,{color:o.orange,bold:!0,children:"Chrome Profile"}),(0,r.jsxs)(u,{flexDirection:"column",marginTop:1,children:[(0,r.jsxs)(c,{color:p?o.green:a===0?o.orange:o.dim,children:[a===0?"\u276F ":" ","Use temporary (no profile)",p?" \u25CF active":""]}),s.map((i,e)=>{let m=e+1===a,w=m?"\u276F ":" ",y=i.isActive?o.green:m?o.orange:void 0;return(0,r.jsxs)(c,{color:y,children:[w,i.label,i.isActive?" \u25CF active":""]},i.name)}),(0,r.jsxs)(c,{color:a===s.length+1?o.orange:o.dim,children:[a===s.length+1?"\u276F ":" ","+ Create new"]})]}),(0,r.jsx)(b,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"select"}],escBackLabel:"back"})]})}export{O as a,E as b,H as c};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as v,b as A,d as G}from"./chunk-OS4VSIHT.js";import{b as x}from"./chunk-KAZGHWGK.js";import{a as S}from"./chunk-JUJ4SAGH.js";import{a as U,b as C}from"./chunk-UJZZDPDY.js";import{a as w}from"./chunk-BZAGVBCX.js";import{C as E,D as $}from"./chunk-W3Z7AZNT.js";import{d,e as m}from"./chunk-AKX4VRRR.js";var k=new Set([d.USECASE,d.SCENARIO,d.AC,d.TEST]);function b(e,t){return!e.superseded.has(t)&&e.trust.get(t)!=="archived"}function h(e,t,n){let s=e.edgesFrom(t).find(o=>o.type===n);return s?e.tipOf(s.dst):null}function O(e,t,n){if(n===d.USECASE)return t;if(n===d.SCENARIO)return h(e,t,m.BELONGS_TO);if(n===d.AC){let s=h(e,t,m.SCOPED_TO);return s?e.nodeLabel.get(s)===d.USECASE?s:h(e,s,m.BELONGS_TO):null}if(n===d.TEST){let s=h(e,t,m.AUTOMATES);return s?h(e,s,m.BELONGS_TO):null}return null}function L(e,t){let n=e.nameOf.get(t);if(n)return n;for(let[s,o]of e.names)if(e.tipOf(o)===t)return s;return t}function F(e,t){return{ucTip:t,display:L(e,t),seamRef:e.nameOf.get(t)??t}}function N(e,t){let n=e.resolve(t);if(!n)return{ok:!1,message:`unknown ref '${t}' \u2014 no test/scenario/ac/use-case by that id or cid`};let s=n.tip,o=e.nodeLabel.get(s);if(!o||!k.has(o))return{ok:!1,message:`'${t}' is a ${o??"missing node"} \u2014 evolve takes a test, scenario, acceptance criterion, or use-case`};let a=O(e,s,o);return!a||e.nodeLabel.get(a)!==d.USECASE?{ok:!1,message:`cannot resolve '${t}' to a parent use-case \u2014 its ${o} chain is broken`}:e.superseded.has(a)?{ok:!1,message:`use-case ${L(e,a)} was removed \u2014 nothing to evolve`}:{ok:!0,target:F(e,a)}}function Z(e,t){return D(e,t)}function D(e,t){let n=[];for(let{cid:o}of e.byLabel(d.SCENARIO)){if(!b(e,o)||!e.edgesFrom(o).some(r=>r.type===m.BELONGS_TO&&e.tipOf(r.dst)===t))continue;let a=e.edgesInto(o).filter(r=>r.type===m.AUTOMATES&&b(e,r.src));if(a.length===0)n.push({scenario:o,test:null});else for(let r of a)n.push({scenario:o,test:r.src})}let s=new Map;for(let{cid:o}of e.byLabel(d.AC)){if(!b(e,o)||O(e,o,d.AC)!==t)continue;let a=e.edgesInto(o).filter(r=>r.type===m.VERIFIES&&b(e,r.src)).map(r=>r.src).sort();s.set(o,a)}return{pairs:n,verifies:s}}function B(e,t){let n=r=>`${r.scenario}\0${r.test??""}`,s=new Set(e.pairs.map(n)),o=new Set(t.pairs.map(n)),a=[];for(let[r,i]of e.verifies){let u=t.verifies.get(r);u&&(i.length===u.length&&i.every((l,g)=>l===u[g])||a.push({ac:r,before:i,after:u}))}return{superseded:e.pairs.filter(r=>!o.has(n(r))),minted:t.pairs.filter(r=>!s.has(n(r))),retained:t.pairs.filter(r=>s.has(n(r))),moves:a}}function _(e,t,n,s,o){let a=i=>t.nameOf.get(i)??i,r=i=>` - ${a(i.scenario)} \xB7 ${i.test?a(i.test):"(no test)"}`;e.out(`evolved: use-case ${n} \u2014 design record ${s.before} \u2192 ${s.after}`),e.out(` superseded ${o.superseded.length} pair(s)`);for(let i of o.superseded)e.out(r(i));e.out(` minted ${o.minted.length} pair(s)`);for(let i of o.minted)e.out(r(i));e.out(` retained ${o.retained.length} pair(s)`);for(let i of o.retained)e.out(r(i));if(o.moves.length===0)e.out(" verifies none moved");else{e.out(" verifies moved:");for(let i of o.moves){let u=l=>l.length>0?l.map(a).join(" + "):"(none)";e.out(` - ${a(i.ac)}: ${u(i.before)} \u2192 ${u(i.after)}`)}}}async function R(e,t,n,s,o,a,r){let i=E(e),u=S(i,t.ucTip);if(!u)return a==="batch"?(s.out(`note: ${t.display} has no design output \u2014 nothing to evolve; run kane-cli design tests --use-case ${t.display} first`),{code:0,outcome:"no-design"}):(v(s,`nothing to evolve \u2014 run kane-cli design tests --use-case ${t.display} first (no design output)`),{code:2,outcome:"no-design"});let l=D(i,t.ucTip),g=[`evolve ${t.display}`,` re-designs use-case ${t.display}`,` affects ${l.pairs.length} pair(s)`,...n.because?[` because ${n.because}`]:[]];if(n.yes)for(let y of g)s.out(y);else{for(let I of g)s.out(I);if(!await s.confirm(`proceed with the re-design of ${t.display}?`))return s.out(a==="batch"?`skipped ${t.display}`:"declined \u2014 nothing evolved"),{code:0,outcome:"declined"}}let p=x(e,i,t.ucTip,n.because),c=await U(r,{verb:"evolve",subject:t.display},()=>o(t.seamRef,{yes:!!n.yes,...n.mode?{mode:n.mode}:{},...n.because?{because:n.because}:{},...p!==void 0?{changeDelta:p.change_delta,priorDesign:p.prior_design}:{}}),y=>({ok:y===0,exitCode:y}));if(c===3)return s.out(`design session for ${t.display} paused \u2014 resume with \`kane-cli design tests --resume\`, then re-run evolve for the diff`),{code:c,outcome:"paused"};if(c!==0)return v(s,`design run for ${t.display} ended with exit code ${c} \u2014 no diff to report`),{code:c,outcome:"failed"};let f=E(e),T=f.tipOf(t.ucTip),P=S(f,T)?.seq;return _(s,f,t.display,{before:u.seq,after:P??"?"},B(l,D(f,T))),{code:0,outcome:"evolved"}}function j(e){let t=new Map,n=0;for(let{cid:o,state:a}of e.staleList()){if(a==="superseded")continue;let r=e.nodeLabel.get(o);if(!r||!k.has(r)||!b(e,o)||!$(e,o))continue;let i=O(e,o,r);!i||e.nodeLabel.get(i)!==d.USECASE||e.superseded.has(i)||(n++,t.has(i)||t.set(i,F(e,i)))}return{targets:[...t.values()].sort((o,a)=>o.display<a.display?-1:o.display>a.display?1:0),staleCount:n}}function M(e,t){for(let{cid:n,state:s}of e.staleList()){if(s==="superseded")continue;let o=e.nodeLabel.get(n);if(!(!o||!k.has(o)||!b(e,n))&&$(e,n)&&O(e,n,o)===t)return!0}return!1}async function q(e,t,n,s={},o=process.cwd()){if(e&&t.fromStale)return v(n,"pass a <ref> OR --from-stale, not both"),2;if(!e&&!t.fromStale)return v(n,"evolve needs a <ref> or --from-stale"),2;let a=A(o,n);if(!a)return 2;let r=s.runDesignForUc??Y,i=s.onChild??(n.isTTY?V(n):void 0);n.out(`evolving ${e??"stale use-cases"}: reading the graph\u2026`);let u=E(a),l,g=null;if(e){let c=N(u,e);if(!c.ok)return v(n,c.message),2;if(!t.because&&S(u,c.target.ucTip)&&!M(u,c.target.ucTip))return v(n,`nothing changed underneath ${e} \u2014 its sources and requirements are current; use --because "<reason>" to re-design anyway`),2;l=[c.target]}else{let{targets:c,staleCount:f}=j(u);if(c.length===0)return n.out("nothing stale \u2014 nothing to evolve"),0;g=`from-stale: ${f} stale node(s) \u2192 ${c.length} use-case(s)`,l=c}if(!t.yes&&!n.isTTY)return v(n,"evolve needs a TTY \u2014 the blast-radius confirm is the point; headless evolution rides `kane-cli maintain reconcile`"),2;if(g&&n.out(g),e){let c=await R(a,l[0],t,n,r,"single",i);return c.outcome==="evolved"&&t.because&&w(a,{ts:new Date().toISOString(),command:"evolve",id:e,verdict:"gap-resolved-evolve",polarity:"preference",by:{kind:"human",id:process.env.USER??"operator"},target:e,reason:t.because}),c.code}let p=0;for(let c of l){let{code:f}=await R(a,c,t,n,r,"batch",i);f!==0&&p===0&&(p=f)}return p}function V(e){let t="",n="evolve";return s=>{s.kind==="start"?(t=s.subject,n=s.verb,e.out(`\u25CF ${C(s.verb).ing} ${s.subject}`)):s.kind==="end"&&e.out(s.ok?`\u25CF ${C(n).ed} ${t} \u2014 ${s.durS}s`:`\u25CF ${n} failed \u2014 ${s.exitCode!=null?`exited ${s.exitCode}`:"error"}${s.fixCmd?` \xB7 ${s.fixCmd}`:""}`)}}var Y=async(e,t)=>{let{designTestsCommand:n}=await import("./bind-WJ5UEMMZ.js"),s=()=>n({useCase:e,force:!0,...t.mode?{mode:t.mode}:t.yes?{mode:"override"}:{},...t.because?{because:t.because}:{},...t.changeDelta!==void 0?{changeDelta:t.changeDelta}:{},...t.priorDesign!==void 0?{priorDesign:t.priorDesign}:{}});if(t.mode!=="agent")return s();let o=process.stdout.write;process.stdout.write=((...a)=>!0);try{return await s()}finally{process.stdout.write=o}};async function ee(e,t){return q(e,t,G(),{})}export{N as a,Z as b,R as c,j as d,q as e,Y as f,ee as g};
2
+ import{a as v,b as A,d as G}from"./chunk-OS4VSIHT.js";import{b as x}from"./chunk-S63XGGBE.js";import{a as w}from"./chunk-BZAGVBCX.js";import{a as S}from"./chunk-JUJ4SAGH.js";import{a as U,b as C}from"./chunk-UJZZDPDY.js";import{C as E,D as $}from"./chunk-R4EGL7VM.js";import{d,e as m}from"./chunk-AKX4VRRR.js";var k=new Set([d.USECASE,d.SCENARIO,d.AC,d.TEST]);function b(e,t){return!e.superseded.has(t)&&e.trust.get(t)!=="archived"}function h(e,t,n){let s=e.edgesFrom(t).find(o=>o.type===n);return s?e.tipOf(s.dst):null}function O(e,t,n){if(n===d.USECASE)return t;if(n===d.SCENARIO)return h(e,t,m.BELONGS_TO);if(n===d.AC){let s=h(e,t,m.SCOPED_TO);return s?e.nodeLabel.get(s)===d.USECASE?s:h(e,s,m.BELONGS_TO):null}if(n===d.TEST){let s=h(e,t,m.AUTOMATES);return s?h(e,s,m.BELONGS_TO):null}return null}function L(e,t){let n=e.nameOf.get(t);if(n)return n;for(let[s,o]of e.names)if(e.tipOf(o)===t)return s;return t}function F(e,t){return{ucTip:t,display:L(e,t),seamRef:e.nameOf.get(t)??t}}function N(e,t){let n=e.resolve(t);if(!n)return{ok:!1,message:`unknown ref '${t}' \u2014 no test/scenario/ac/use-case by that id or cid`};let s=n.tip,o=e.nodeLabel.get(s);if(!o||!k.has(o))return{ok:!1,message:`'${t}' is a ${o??"missing node"} \u2014 evolve takes a test, scenario, acceptance criterion, or use-case`};let a=O(e,s,o);return!a||e.nodeLabel.get(a)!==d.USECASE?{ok:!1,message:`cannot resolve '${t}' to a parent use-case \u2014 its ${o} chain is broken`}:e.superseded.has(a)?{ok:!1,message:`use-case ${L(e,a)} was removed \u2014 nothing to evolve`}:{ok:!0,target:F(e,a)}}function Z(e,t){return D(e,t)}function D(e,t){let n=[];for(let{cid:o}of e.byLabel(d.SCENARIO)){if(!b(e,o)||!e.edgesFrom(o).some(r=>r.type===m.BELONGS_TO&&e.tipOf(r.dst)===t))continue;let a=e.edgesInto(o).filter(r=>r.type===m.AUTOMATES&&b(e,r.src));if(a.length===0)n.push({scenario:o,test:null});else for(let r of a)n.push({scenario:o,test:r.src})}let s=new Map;for(let{cid:o}of e.byLabel(d.AC)){if(!b(e,o)||O(e,o,d.AC)!==t)continue;let a=e.edgesInto(o).filter(r=>r.type===m.VERIFIES&&b(e,r.src)).map(r=>r.src).sort();s.set(o,a)}return{pairs:n,verifies:s}}function B(e,t){let n=r=>`${r.scenario}\0${r.test??""}`,s=new Set(e.pairs.map(n)),o=new Set(t.pairs.map(n)),a=[];for(let[r,i]of e.verifies){let u=t.verifies.get(r);u&&(i.length===u.length&&i.every((l,g)=>l===u[g])||a.push({ac:r,before:i,after:u}))}return{superseded:e.pairs.filter(r=>!o.has(n(r))),minted:t.pairs.filter(r=>!s.has(n(r))),retained:t.pairs.filter(r=>s.has(n(r))),moves:a}}function _(e,t,n,s,o){let a=i=>t.nameOf.get(i)??i,r=i=>` - ${a(i.scenario)} \xB7 ${i.test?a(i.test):"(no test)"}`;e.out(`evolved: use-case ${n} \u2014 design record ${s.before} \u2192 ${s.after}`),e.out(` superseded ${o.superseded.length} pair(s)`);for(let i of o.superseded)e.out(r(i));e.out(` minted ${o.minted.length} pair(s)`);for(let i of o.minted)e.out(r(i));e.out(` retained ${o.retained.length} pair(s)`);for(let i of o.retained)e.out(r(i));if(o.moves.length===0)e.out(" verifies none moved");else{e.out(" verifies moved:");for(let i of o.moves){let u=l=>l.length>0?l.map(a).join(" + "):"(none)";e.out(` - ${a(i.ac)}: ${u(i.before)} \u2192 ${u(i.after)}`)}}}async function R(e,t,n,s,o,a,r){let i=E(e),u=S(i,t.ucTip);if(!u)return a==="batch"?(s.out(`note: ${t.display} has no design output \u2014 nothing to evolve; run kane-cli design tests --use-case ${t.display} first`),{code:0,outcome:"no-design"}):(v(s,`nothing to evolve \u2014 run kane-cli design tests --use-case ${t.display} first (no design output)`),{code:2,outcome:"no-design"});let l=D(i,t.ucTip),g=[`evolve ${t.display}`,` re-designs use-case ${t.display}`,` affects ${l.pairs.length} pair(s)`,...n.because?[` because ${n.because}`]:[]];if(n.yes)for(let y of g)s.out(y);else{for(let I of g)s.out(I);if(!await s.confirm(`proceed with the re-design of ${t.display}?`))return s.out(a==="batch"?`skipped ${t.display}`:"declined \u2014 nothing evolved"),{code:0,outcome:"declined"}}let p=x(e,i,t.ucTip,n.because),c=await U(r,{verb:"evolve",subject:t.display},()=>o(t.seamRef,{yes:!!n.yes,...n.mode?{mode:n.mode}:{},...n.because?{because:n.because}:{},...p!==void 0?{changeDelta:p.change_delta,priorDesign:p.prior_design}:{}}),y=>({ok:y===0,exitCode:y}));if(c===3)return s.out(`design session for ${t.display} paused \u2014 resume with \`kane-cli design tests --resume\`, then re-run evolve for the diff`),{code:c,outcome:"paused"};if(c!==0)return v(s,`design run for ${t.display} ended with exit code ${c} \u2014 no diff to report`),{code:c,outcome:"failed"};let f=E(e),T=f.tipOf(t.ucTip),P=S(f,T)?.seq;return _(s,f,t.display,{before:u.seq,after:P??"?"},B(l,D(f,T))),{code:0,outcome:"evolved"}}function j(e){let t=new Map,n=0;for(let{cid:o,state:a}of e.staleList()){if(a==="superseded")continue;let r=e.nodeLabel.get(o);if(!r||!k.has(r)||!b(e,o)||!$(e,o))continue;let i=O(e,o,r);!i||e.nodeLabel.get(i)!==d.USECASE||e.superseded.has(i)||(n++,t.has(i)||t.set(i,F(e,i)))}return{targets:[...t.values()].sort((o,a)=>o.display<a.display?-1:o.display>a.display?1:0),staleCount:n}}function M(e,t){for(let{cid:n,state:s}of e.staleList()){if(s==="superseded")continue;let o=e.nodeLabel.get(n);if(!(!o||!k.has(o)||!b(e,n))&&$(e,n)&&O(e,n,o)===t)return!0}return!1}async function q(e,t,n,s={},o=process.cwd()){if(e&&t.fromStale)return v(n,"pass a <ref> OR --from-stale, not both"),2;if(!e&&!t.fromStale)return v(n,"evolve needs a <ref> or --from-stale"),2;let a=A(o,n);if(!a)return 2;let r=s.runDesignForUc??Y,i=s.onChild??(n.isTTY?V(n):void 0);n.out(`evolving ${e??"stale use-cases"}: reading the graph\u2026`);let u=E(a),l,g=null;if(e){let c=N(u,e);if(!c.ok)return v(n,c.message),2;if(!t.because&&S(u,c.target.ucTip)&&!M(u,c.target.ucTip))return v(n,`nothing changed underneath ${e} \u2014 its sources and requirements are current; use --because "<reason>" to re-design anyway`),2;l=[c.target]}else{let{targets:c,staleCount:f}=j(u);if(c.length===0)return n.out("nothing stale \u2014 nothing to evolve"),0;g=`from-stale: ${f} stale node(s) \u2192 ${c.length} use-case(s)`,l=c}if(!t.yes&&!n.isTTY)return v(n,"evolve needs a TTY \u2014 the blast-radius confirm is the point; headless evolution rides `kane-cli maintain reconcile`"),2;if(g&&n.out(g),e){let c=await R(a,l[0],t,n,r,"single",i);return c.outcome==="evolved"&&t.because&&w(a,{ts:new Date().toISOString(),command:"evolve",id:e,verdict:"gap-resolved-evolve",polarity:"preference",by:{kind:"human",id:process.env.USER??"operator"},target:e,reason:t.because}),c.code}let p=0;for(let c of l){let{code:f}=await R(a,c,t,n,r,"batch",i);f!==0&&p===0&&(p=f)}return p}function V(e){let t="",n="evolve";return s=>{s.kind==="start"?(t=s.subject,n=s.verb,e.out(`\u25CF ${C(s.verb).ing} ${s.subject}`)):s.kind==="end"&&e.out(s.ok?`\u25CF ${C(n).ed} ${t} \u2014 ${s.durS}s`:`\u25CF ${n} failed \u2014 ${s.exitCode!=null?`exited ${s.exitCode}`:"error"}${s.fixCmd?` \xB7 ${s.fixCmd}`:""}`)}}var Y=async(e,t)=>{let{designTestsCommand:n}=await import("./bind-5WELCZ4S.js"),s=()=>n({useCase:e,force:!0,...t.mode?{mode:t.mode}:t.yes?{mode:"override"}:{},...t.because?{because:t.because}:{},...t.changeDelta!==void 0?{changeDelta:t.changeDelta}:{},...t.priorDesign!==void 0?{priorDesign:t.priorDesign}:{}});if(t.mode!=="agent")return s();let o=process.stdout.write;process.stdout.write=((...a)=>!0);try{return await s()}finally{process.stdout.write=o}};async function ee(e,t){return q(e,t,G(),{})}export{N as a,Z as b,R as c,j as d,q as e,Y as f,ee as g};