@testmuai/kane-cli 0.8.13 → 0.8.14

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 (300) hide show
  1. package/dist/{ChatSurface-B6ZIO3JL.js → ChatSurface-AVL3TJA2.js} +3 -3
  2. package/dist/{ChromeProfilePicker-QSICCUMV.js → ChromeProfilePicker-WJZJOZ6Z.js} +1 -1
  3. package/dist/{CliFeedbackPrompt-LLLNSKW2.js → CliFeedbackPrompt-65BQF5G5.js} +1 -1
  4. package/dist/{CliUploadProgress-N5IY66T2.js → CliUploadProgress-HEBZYKGN.js} +1 -1
  5. package/dist/{ConfigView-UQIRPENS.js → ConfigView-JEVQ2SO4.js} +1 -1
  6. package/dist/EvidenceViewOffer-5MB4ZXKM.js +2 -0
  7. package/dist/FolderPicker-SYFXH6D5.js +2 -0
  8. package/dist/{InfoBox-ZGSLEOPE.js → InfoBox-KM5DLBCV.js} +1 -1
  9. package/dist/{LinksBox-JFT44YUK.js → LinksBox-FQA36GTV.js} +1 -1
  10. package/dist/{ProfilesView-WZSPK3HF.js → ProfilesView-76KGHTMK.js} +1 -1
  11. package/dist/{ProjectPicker-SBBGVF4L.js → ProjectPicker-65YOU46H.js} +1 -1
  12. package/dist/{SaveSessionPrompt-F3563T3C.js → SaveSessionPrompt-QD6BNTWO.js} +1 -1
  13. package/dist/ScrollbackTap-QHJOFYMC.js +2 -0
  14. package/dist/SingleShotApp-U54ETXS3.js +2 -0
  15. package/dist/{SummaryBox-6N6NESLI.js → SummaryBox-N2B6DUDD.js} +1 -1
  16. package/dist/TestMdRunView-WA4TC5PT.js +2 -0
  17. package/dist/{TestrunEvidenceTable-JLJBJ76Q.js → TestrunEvidenceTable-3WLQVTF4.js} +1 -1
  18. package/dist/{WhoamiView-PNVUCWLB.js → WhoamiView-T26HA4ZZ.js} +1 -1
  19. package/dist/agent-parse-XMWVKCRD.js +2 -0
  20. package/dist/{app-download-NNB52ZRJ.js → app-download-XKZWFMEK.js} +1 -1
  21. package/dist/attach-target-V6LECVES.js +2 -0
  22. package/dist/{auth-JIDDELKY.js → auth-PPJANIMZ.js} +1 -1
  23. package/dist/{binary-LXYAW7WQ.js → binary-DKWWODT2.js} +1 -1
  24. package/dist/bind-62AZYFAY.js +15 -0
  25. package/dist/{bootstrap-THOC3SS7.js → bootstrap-6IJNZIPT.js} +1 -1
  26. package/dist/bridge-X5DEJL6F.js +2 -0
  27. package/dist/{changelog-BSMZXLTG.js → changelog-UTGJ7FSP.js} +1 -1
  28. package/dist/chat-committer-HDE3TP5I.js +2 -0
  29. package/dist/chat-controller-3EPK7UZG.js +2 -0
  30. package/dist/chunk-22QIVSQR.js +29 -0
  31. package/dist/{chunk-FNIL4G3V.js → chunk-2BFXT7VQ.js} +3 -3
  32. package/dist/{chunk-3FXNQTCE.js → chunk-2RMHDOP4.js} +1 -1
  33. package/dist/{chunk-7GUFVQOQ.js → chunk-3BHRGHIZ.js} +1 -1
  34. package/dist/{chunk-EEFZXZTZ.js → chunk-3IXEARDX.js} +1 -1
  35. package/dist/chunk-3N6IAVD5.js +7 -0
  36. package/dist/{chunk-I75FRXKE.js → chunk-3SPOJWRA.js} +1 -1
  37. package/dist/chunk-3YX3RQXO.js +2 -0
  38. package/dist/chunk-42FHKRPA.js +4 -0
  39. package/dist/{chunk-VYMMGWVO.js → chunk-4BBDKWM3.js} +1 -1
  40. package/dist/{chunk-J2UN2AHO.js → chunk-4K5XTIJ6.js} +1 -1
  41. package/dist/chunk-52WM3XYO.js +4 -0
  42. package/dist/{chunk-WUV3FJ7C.js → chunk-53MPG2J3.js} +1 -1
  43. package/dist/{chunk-R7QAS6LZ.js → chunk-55YDTPB7.js} +1 -1
  44. package/dist/{chunk-IDX3TOPY.js → chunk-5LJRZI7S.js} +1 -1
  45. package/dist/chunk-66MOZKD2.js +2 -0
  46. package/dist/{chunk-2X3TANEV.js → chunk-6F6YI3ZG.js} +1 -1
  47. package/dist/chunk-6LGED4FC.js +35 -0
  48. package/dist/chunk-73ULUGBM.js +5 -0
  49. package/dist/{chunk-F5AI3UVS.js → chunk-75I46VTM.js} +2 -2
  50. package/dist/{chunk-SEKJZOKW.js → chunk-7L25ZNNP.js} +1 -1
  51. package/dist/chunk-7O54QURK.js +2 -0
  52. package/dist/{chunk-XAM5E27U.js → chunk-7RAI77XD.js} +1 -1
  53. package/dist/{chunk-PWRIG6UB.js → chunk-AC7BPO4X.js} +1 -1
  54. package/dist/chunk-AHXOKBVE.js +7 -0
  55. package/dist/{chunk-DNNZ353O.js → chunk-ALCE5RLK.js} +1 -1
  56. package/dist/{chunk-AQWTK6IN.js → chunk-ARG56PJG.js} +1 -1
  57. package/dist/{chunk-33GXXC2L.js → chunk-B2ZGG7WM.js} +1 -1
  58. package/dist/{chunk-LAQBCZ5A.js → chunk-BAKJPQGU.js} +1 -1
  59. package/dist/{chunk-DIM5X2FR.js → chunk-BJYGWXVP.js} +1 -1
  60. package/dist/chunk-C74ABM24.js +2 -0
  61. package/dist/chunk-CGT4NFQN.js +8 -0
  62. package/dist/{chunk-EV64VI66.js → chunk-CRZUBDJ3.js} +1 -1
  63. package/dist/{chunk-EXLXV5OU.js → chunk-DA57DXCF.js} +1 -1
  64. package/dist/{chunk-PUM5J56E.js → chunk-EMSLJTYN.js} +1 -1
  65. package/dist/{chunk-YEZYO5QH.js → chunk-FFFB5BXL.js} +1 -1
  66. package/dist/{chunk-WIAZN7G4.js → chunk-FFVNISYH.js} +1 -1
  67. package/dist/chunk-FQNQVC5O.js +5 -0
  68. package/dist/{chunk-UF4JZXEE.js → chunk-GESG672R.js} +1 -1
  69. package/dist/{chunk-XL6HDWM3.js → chunk-GKZ2KVE6.js} +1 -1
  70. package/dist/chunk-GP7WD4UY.js +4 -0
  71. package/dist/{chunk-PYQS5ST6.js → chunk-GPIXV7AV.js} +2 -2
  72. package/dist/chunk-H6TNBKGR.js +5 -0
  73. package/dist/chunk-HOA4VWSD.js +5 -0
  74. package/dist/chunk-IE3OO5GI.js +2 -0
  75. package/dist/chunk-IICQ5KRD.js +5 -0
  76. package/dist/{chunk-K4SULRBL.js → chunk-IQ7GPETF.js} +1 -1
  77. package/dist/{chunk-3M2D7UUI.js → chunk-IQ7NGOAT.js} +1 -1
  78. package/dist/{chunk-TMRLBSIA.js → chunk-J7NRD4Q7.js} +1 -1
  79. package/dist/{chunk-FE6XRABM.js → chunk-JH6E632O.js} +1 -1
  80. package/dist/{chunk-XH2KDLZO.js → chunk-JJJSDDQ2.js} +1 -1
  81. package/dist/{chunk-BTBUIL4Q.js → chunk-JKX57HA7.js} +1 -1
  82. package/dist/{chunk-VJ3ES3RR.js → chunk-K7K23DIQ.js} +1 -1
  83. package/dist/chunk-KN65CUNT.js +15 -0
  84. package/dist/{chunk-CAO3XRA2.js → chunk-KOL6ZWOQ.js} +1 -1
  85. package/dist/{chunk-MCKBJIBB.js → chunk-KOPP4CJW.js} +1 -1
  86. package/dist/chunk-KZG4E5RM.js +2 -0
  87. package/dist/{chunk-J3Q63NFG.js → chunk-L4M7753M.js} +1 -1
  88. package/dist/{chunk-BJAHVN2F.js → chunk-L6MOO4WT.js} +1 -1
  89. package/dist/chunk-LBNADEQN.js +8 -0
  90. package/dist/{chunk-Q4YAJJPP.js → chunk-LL5DQO6V.js} +1 -1
  91. package/dist/chunk-LNV7C2YO.js +6 -0
  92. package/dist/{chunk-JX2CAVX6.js → chunk-LR5DJ6EN.js} +1 -1
  93. package/dist/{chunk-IZU5ND2C.js → chunk-M7DN6FO3.js} +1 -1
  94. package/dist/chunk-MLRO7OH3.js +9 -0
  95. package/dist/{chunk-DMLYUTS4.js → chunk-MNE5VMHT.js} +1 -1
  96. package/dist/{chunk-TDNM22BQ.js → chunk-N7ZRF5K3.js} +1 -1
  97. package/dist/{chunk-TXZ66K4Q.js → chunk-NBMLBCJ3.js} +1 -1
  98. package/dist/{chunk-KSLJOUH4.js → chunk-NDCRJXYF.js} +1 -1
  99. package/dist/{chunk-XS3HIVNS.js → chunk-NOLYYHVG.js} +1 -1
  100. package/dist/{chunk-IWVA37B6.js → chunk-O25AL4B7.js} +1 -1
  101. package/dist/{chunk-AIVOYTYQ.js → chunk-O2APH6TZ.js} +1 -1
  102. package/dist/{chunk-KAZGHWGK.js → chunk-O3XBIURC.js} +1 -1
  103. package/dist/{chunk-ZOSY2PJM.js → chunk-O5AS2ZIX.js} +1 -1
  104. package/dist/{chunk-DXFMELKC.js → chunk-O6U2HU5M.js} +1 -1
  105. package/dist/{chunk-NUWOQS6L.js → chunk-OH2NSBO6.js} +1 -1
  106. package/dist/{chunk-ARU6KAGY.js → chunk-OO5GMBVI.js} +1 -1
  107. package/dist/chunk-OPL2MIQG.js +2 -0
  108. package/dist/chunk-P3JUE2RM.js +17 -0
  109. package/dist/{chunk-D4G3SEBU.js → chunk-PGU64EWQ.js} +1 -1
  110. package/dist/{chunk-GILD6RGH.js → chunk-Q7XBMBMR.js} +1 -1
  111. package/dist/{chunk-OHK6V7JX.js → chunk-QJ5O27SJ.js} +1 -1
  112. package/dist/{chunk-KXUTO5WC.js → chunk-QPUVOVD7.js} +1 -1
  113. package/dist/{chunk-NM76SG3S.js → chunk-RBHQXWR7.js} +1 -1
  114. package/dist/{chunk-LWQNRZH3.js → chunk-RH6KFHJB.js} +1 -1
  115. package/dist/{chunk-FUP4AP6J.js → chunk-RQLU4NDG.js} +1 -1
  116. package/dist/{chunk-MXDWS7S4.js → chunk-SFTFHFG3.js} +7 -7
  117. package/dist/{chunk-4PARDPK2.js → chunk-SGHP44WS.js} +1 -1
  118. package/dist/{chunk-6AZNGOLH.js → chunk-SQDQADWD.js} +1 -1
  119. package/dist/{chunk-N2I23ANS.js → chunk-SX56MVUO.js} +1 -1
  120. package/dist/{chunk-O5U6EAL3.js → chunk-TCAHDVII.js} +1 -1
  121. package/dist/chunk-TNBF5OMZ.js +2 -0
  122. package/dist/chunk-TU6IMGWO.js +2 -0
  123. package/dist/{chunk-5G22NOZK.js → chunk-UHT5SVP5.js} +1 -1
  124. package/dist/{chunk-UZCSVEWP.js → chunk-UXH3RMQ7.js} +1 -1
  125. package/dist/{chunk-K2UEVCIJ.js → chunk-VNFCX2SH.js} +1 -1
  126. package/dist/{chunk-NU45ROHH.js → chunk-WBHSPN55.js} +2 -2
  127. package/dist/chunk-WILT62DP.js +16 -0
  128. package/dist/{chunk-QD2BUO5M.js → chunk-WOA7VCGA.js} +1 -1
  129. package/dist/{chunk-RN5ERSV2.js → chunk-WR42Q3HU.js} +1 -1
  130. package/dist/chunk-X5276I5H.js +9 -0
  131. package/dist/{chunk-477DYMXZ.js → chunk-X74PP5NJ.js} +1 -1
  132. package/dist/{chunk-KV5BOFPK.js → chunk-XGHMZJGI.js} +2 -2
  133. package/dist/{chunk-XS2LZFCH.js → chunk-YCH7H7JX.js} +1 -1
  134. package/dist/{chunk-7KIIM6H7.js → chunk-YHR2YAN5.js} +1 -1
  135. package/dist/chunk-YHVG7V3E.js +21 -0
  136. package/dist/chunk-YLQHY4A7.js +2 -0
  137. package/dist/{chunk-KGKJU27A.js → chunk-YYYQ5MVD.js} +1 -1
  138. package/dist/{chunk-W2UYUV47.js → chunk-ZA4M4O7E.js} +2 -2
  139. package/dist/chunk-ZKEOPIQ3.js +9 -0
  140. package/dist/chunk-ZUZ6QJRA.js +23 -0
  141. package/dist/{chunk-3SP4JVDN.js → chunk-ZWHPIR2Z.js} +2 -2
  142. package/dist/chunk-ZZTZJPT2.js +88 -0
  143. package/dist/committer-IYQPXG6C.js +2 -0
  144. package/dist/{config-BCGD2FEX.js → config-3AKWRTFS.js} +1 -1
  145. package/dist/cover-cmd-ZLAWMEC2.js +3 -0
  146. package/dist/{credentials-YNH5BU2Z.js → credentials-Q4WH5CBN.js} +1 -1
  147. package/dist/{deps-bundle-LOFI4DAJ.js → deps-bundle-RVZK6LZJ.js} +1 -1
  148. package/dist/{deps-resolve-GA6IPHVZ.js → deps-resolve-6F2U4TJP.js} +1 -1
  149. package/dist/design-committer-J57IAAA5.js +2 -0
  150. package/dist/dispatch-46BETGXY.js +2 -0
  151. package/dist/{doctor-W5TQBYB5.js → doctor-WRPG56HH.js} +1 -1
  152. package/dist/docx-convert-WPZS6OIC.js +2 -0
  153. package/dist/{dossier-Y6TJWFZU.js → dossier-UGJMYYAB.js} +1 -1
  154. package/dist/evidence-XWR32HWP.js +2 -0
  155. package/dist/evolve-cmd-27ZQN6YB.js +2 -0
  156. package/dist/explain-H5HJEDEF.js +2 -0
  157. package/dist/explain-cmd-JCJTXVZY.js +9 -0
  158. package/dist/{explain-cmd-XCRO4AS6.js → explain-cmd-R45I5MT7.js} +1 -1
  159. package/dist/extract-bind-D5BYYGYA.js +14 -0
  160. package/dist/{extract-cmd-7FKQJNS7.js → extract-cmd-CCYW7FIY.js} +3 -3
  161. package/dist/feeder-RSHMGW6B.js +2 -0
  162. package/dist/gaps-cmd-3VJKQ25D.js +3 -0
  163. package/dist/{generate-headless-OBMB5CSB.js → generate-headless-2M6UT3IK.js} +2 -2
  164. package/dist/headless-io-3A3BZVQ5.js +2 -0
  165. package/dist/index.js +188 -205
  166. package/dist/ingest-QGLVY7ND.js +2 -0
  167. package/dist/ingest-cmd-HVTUK264.js +2 -0
  168. package/dist/install-5WJLE7XT.js +2 -0
  169. package/dist/interactive-bind-OJCYNQPI.js +26 -0
  170. package/dist/lifecycle-cmd-GWFGUGTC.js +2 -0
  171. package/dist/{list-cmd-V3HJ5K4O.js → list-cmd-AXDW64OY.js} +1 -1
  172. package/dist/{list-commands-SH4HPFI4.js → list-commands-YNZ6EFIF.js} +1 -1
  173. package/dist/{locks-cmd-CSVSWY2Y.js → locks-cmd-67OHQZNV.js} +1 -1
  174. package/dist/logical-ids-DN6IZSUM.js +2 -0
  175. package/dist/login-flow-PRXFPRYZ.js +2 -0
  176. package/dist/maintenance-cmd-QEMK6YNV.js +2 -0
  177. package/dist/{mobile-prompts-UZTRJ3L7.js → mobile-prompts-OXHA5GHJ.js} +1 -1
  178. package/dist/{objective-variable-gate-3VUXNDCZ.js → objective-variable-gate-76GYUHEP.js} +1 -1
  179. package/dist/open-provider-E5VUGFNE.js +2 -0
  180. package/dist/pdf-convert-5H4HQNN3.js +2 -0
  181. package/dist/{persist-recorded-session-QMRY4DOF.js → persist-recorded-session-KWPH37HI.js} +1 -1
  182. package/dist/phase-seed-HKJ2EF7R.js +2 -0
  183. package/dist/pipeline-A2OGF4XW.js +2 -0
  184. package/dist/prepare-target-P6BWJZBZ.js +2 -0
  185. package/dist/readmodel-IBFRM6EO.js +2 -0
  186. package/dist/reconcile-cmd-V7TDYETT.js +2 -0
  187. package/dist/reconcile-deps-X6IGH4CA.js +4 -0
  188. package/dist/reconcile-engine-OGXSIE7O.js +2 -0
  189. package/dist/{recording-banner-7E75ERQJ.js → recording-banner-IZWN2XFY.js} +1 -1
  190. package/dist/records-TJJJWBUD.js +2 -0
  191. package/dist/registry-GOLIFVK5.js +2 -0
  192. package/dist/{require-project-folder-LBUYWQOF.js → require-project-folder-PEEUITK6.js} +1 -1
  193. package/dist/{resolve-run-intent-GHISMXLZ.js → resolve-run-intent-JGXXE45Y.js} +1 -1
  194. package/dist/{resolver-7JC5VZ4S.js → resolver-TY7XLJBN.js} +1 -1
  195. package/dist/revert-6BBBK3I4.js +2 -0
  196. package/dist/review-cmd-74YTPT7E.js +5 -0
  197. package/dist/run-DN4XARP2.js +2 -0
  198. package/dist/run-GRYWYKIH.js +2 -0
  199. package/dist/{run-test-md-5LPCKCW7.js → run-test-md-DFCKCQ4T.js} +2 -2
  200. package/dist/sessions-NH7WQWMX.js +2 -0
  201. package/dist/{sessions-cmd-VDQGRBEM.js → sessions-cmd-DV442ZCY.js} +1 -1
  202. package/dist/{skill-installer-YQPZZB7I.js → skill-installer-GRU3HOYF.js} +1 -1
  203. package/dist/{spawner-X2FOOONV.js → spawner-LNMD4NJF.js} +1 -1
  204. package/dist/store-guard-Q4MYZQHF.js +2 -0
  205. package/dist/structured-answers-NADW6D44.js +5 -0
  206. package/dist/sync-cmd-H6Y5EB3L.js +2 -0
  207. package/dist/sync-setup-THGRBKTA.js +2 -0
  208. package/dist/sync-setup-ui-RC727VK6.js +3 -0
  209. package/dist/tcg-generate-SZZ7MJXY.js +2 -0
  210. package/dist/testmd-actions-MRIUOOXO.js +2 -0
  211. package/dist/testmd-sync-UYVJ47BN.js +2 -0
  212. package/dist/token-refresh-KN5JK2U4.js +2 -0
  213. package/dist/{validate-basic-GTSVZFQI.js → validate-basic-RCBEELSB.js} +1 -1
  214. package/dist/{variable-receipt-IHQAYWMZ.js → variable-receipt-JHRW73Z6.js} +1 -1
  215. package/dist/verdicts-XFXDRND4.js +2 -0
  216. package/dist/{version-check-IPEPJZDX.js → version-check-Z774UWW3.js} +1 -1
  217. package/dist/{view-cmd-SXXNDZIC.js → view-cmd-I4LQGJ2X.js} +1 -1
  218. package/dist/walk-session-FP52IGLB.js +2 -0
  219. package/dist/with-telemetry-P6RUPWBH.js +2 -0
  220. package/package.json +12 -11
  221. package/dist/EvidenceViewOffer-AZRAILJQ.js +0 -2
  222. package/dist/FolderPicker-OJFR7AKZ.js +0 -2
  223. package/dist/ScrollbackTap-Q3IOKNMS.js +0 -2
  224. package/dist/SingleShotApp-72D5VVLE.js +0 -2
  225. package/dist/TestMdRunView-4OA52DA2.js +0 -2
  226. package/dist/bind-F36JFHUK.js +0 -12
  227. package/dist/bridge-KMDML2NB.js +0 -2
  228. package/dist/chat-committer-RAOIL2T6.js +0 -2
  229. package/dist/chat-controller-YJCNU76T.js +0 -2
  230. package/dist/chunk-4WOVHRI2.js +0 -15
  231. package/dist/chunk-54JZ6VEW.js +0 -4
  232. package/dist/chunk-5DT7PIGB.js +0 -5
  233. package/dist/chunk-6FCPS2VT.js +0 -4
  234. package/dist/chunk-6IAA644J.js +0 -9
  235. package/dist/chunk-6J635CRI.js +0 -5
  236. package/dist/chunk-AGRUULPT.js +0 -4
  237. package/dist/chunk-BZTWTYQQ.js +0 -6
  238. package/dist/chunk-CUSTYILP.js +0 -2
  239. package/dist/chunk-DBIBROYW.js +0 -5
  240. package/dist/chunk-I27YRAGO.js +0 -7
  241. package/dist/chunk-IAHKTEET.js +0 -2
  242. package/dist/chunk-IVQX3AKL.js +0 -4
  243. package/dist/chunk-K6RAOZHP.js +0 -4
  244. package/dist/chunk-KO3FL2XW.js +0 -26
  245. package/dist/chunk-L32DKFRQ.js +0 -16
  246. package/dist/chunk-LPDBTGO5.js +0 -21
  247. package/dist/chunk-N7Z7BQYO.js +0 -3
  248. package/dist/chunk-NVGBE2DR.js +0 -2
  249. package/dist/chunk-OS4VSIHT.js +0 -4
  250. package/dist/chunk-OTMAFCZK.js +0 -8
  251. package/dist/chunk-P5MJMM3X.js +0 -85
  252. package/dist/chunk-QQ5MHSSY.js +0 -2
  253. package/dist/chunk-T7DGNWI2.js +0 -17
  254. package/dist/chunk-UH2ZTX4E.js +0 -2
  255. package/dist/chunk-W3Z7AZNT.js +0 -4
  256. package/dist/chunk-XMTSHHYQ.js +0 -4
  257. package/dist/committer-C6UCDYMC.js +0 -2
  258. package/dist/cover-cmd-5LPHIOSI.js +0 -3
  259. package/dist/design-committer-UPC6NZUF.js +0 -2
  260. package/dist/dispatch-FRCPK3AZ.js +0 -2
  261. package/dist/docx-convert-BIV5T7F5.js +0 -2
  262. package/dist/evidence-FHO36EEV.js +0 -2
  263. package/dist/evolve-cmd-6RXLKERE.js +0 -2
  264. package/dist/explain-3HAZY7Q6.js +0 -2
  265. package/dist/explain-cmd-RMJPXD4U.js +0 -9
  266. package/dist/extract-bind-BFJPRNPQ.js +0 -10
  267. package/dist/feeder-IOR3XRNF.js +0 -2
  268. package/dist/gaps-cmd-FDJ3PT4C.js +0 -3
  269. package/dist/headless-io-66RG5NN5.js +0 -2
  270. package/dist/ingest-TTUQ7UDK.js +0 -2
  271. package/dist/ingest-cmd-AV66Q5LC.js +0 -2
  272. package/dist/install-SFJ2FFQ6.js +0 -2
  273. package/dist/interactive-bind-N5AQB26T.js +0 -25
  274. package/dist/lifecycle-cmd-KSMETBPP.js +0 -2
  275. package/dist/logical-ids-MLXAH45L.js +0 -2
  276. package/dist/login-flow-ODVWEPRU.js +0 -2
  277. package/dist/maintenance-cmd-VFYGKY3X.js +0 -2
  278. package/dist/pdf-convert-OZIRUADA.js +0 -2
  279. package/dist/phase-seed-BMOSAA74.js +0 -2
  280. package/dist/pipeline-5FHWZAXK.js +0 -2
  281. package/dist/prepare-target-UJEY2FSR.js +0 -2
  282. package/dist/readmodel-TDRFVDVI.js +0 -2
  283. package/dist/reconcile-cmd-2QHZML2L.js +0 -2
  284. package/dist/reconcile-deps-ZBWUY3SM.js +0 -4
  285. package/dist/reconcile-engine-YC4RQYF2.js +0 -2
  286. package/dist/records-JLS63SDI.js +0 -2
  287. package/dist/registry-JJTRUPH7.js +0 -2
  288. package/dist/revert-PRR3D4XM.js +0 -2
  289. package/dist/review-cmd-SAGIKWEW.js +0 -4
  290. package/dist/run-43ACVPJK.js +0 -2
  291. package/dist/run-EOTOXNQO.js +0 -2
  292. package/dist/sessions-GIEXOCE4.js +0 -2
  293. package/dist/structured-answers-YAVW65G4.js +0 -5
  294. package/dist/tcg-generate-V4QRNEZV.js +0 -2
  295. package/dist/testmd-actions-2UMU3QMV.js +0 -2
  296. package/dist/testmd-sync-UBXDLWYD.js +0 -2
  297. package/dist/token-refresh-NL5AM446.js +0 -2
  298. package/dist/verdicts-QU6W3TUF.js +0 -2
  299. package/dist/walk-session-7JVB4Z5S.js +0 -2
  300. package/dist/with-telemetry-LRI7H6DH.js +0 -2
@@ -1,5 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as q,c as $}from"./chunk-PDXZROJM.js";import{U as V}from"./chunk-LPDBTGO5.js";import{b as z}from"./chunk-5GUD3CIH.js";import{a as ft,b as R}from"./chunk-NBXYL2JT.js";import{a as B}from"./chunk-BPMSNGXQ.js";import{a as M}from"./chunk-DHJSM5DT.js";import{a as F}from"./chunk-NLCCBXXV.js";import{a as P}from"./chunk-RZ4F3BHX.js";import{e as gt}from"./chunk-UR6MHSHU.js";import{readFileSync as C,existsSync as j,readdirSync as qt,mkdirSync as D,writeFileSync as O}from"fs";import{readFile as pt,unlink as $t}from"fs/promises";import{join as E}from"path";import{existsSync as Ct,mkdirSync as jt,readdirSync as at,writeFileSync as Dt}from"fs";import{join as x}from"path";import{randomUUID as v}from"crypto";var mt=["children","instructions","branches","module_content","true_branch","false_branch"];function H(n){let t=new Map,i=s=>{if(!s||typeof s!="object")return;let r=s;if(Array.isArray(r.operations))for(let e of r.operations){let o=e.operation_id;typeof o=="string"&&o&&!t.has(o)&&t.set(o,r)}for(let e of mt){let o=r[e];Array.isArray(o)?o.forEach(i):o&&typeof o=="object"&&i(o)}};return n.forEach(i),t}function J(n,t){let i=new Map;for(let s of n){let r=s.action_id?t.get(s.action_id):void 0;if(!r)continue;let e=i.get(r)??[];e.push(s),i.set(r,e)}return i.size===0?null:[...i].map(([s,r])=>Et(s,r))}function ht(n){if(!n.timestamp||n.duration_ms==null)return"";let t=new Date(n.timestamp);return isNaN(t.getTime())?"":new Date(t.getTime()+n.duration_ms).toISOString()}function G(n){if(n!=null)try{return JSON.parse(n)}catch{return n}}function K(n,t,i){let s=n.user_variables,r=typeof s=="string",e;try{e=r?JSON.parse(s):s??[]}catch{return}if(!Array.isArray(e)||e.length===0)return;let o=e.find(l=>t&&l.name===t)??(e.length===1?e[0]:void 0);o&&(o.value=i,n.user_variables=r?JSON.stringify(e):e)}function Et(n,t){let i=structuredClone(n),s=t[0],r=t[t.length-1];switch(i.status=t.find(e=>e.status!=="success")?.status??s.status,i.start_timestamp=s.timestamp??i.start_timestamp,i.end_timestamp=ht(r)||i.end_timestamp,i.content_type){case"api":{let e=r.action_params?.api_data?.response;e&&typeof e=="object"&&(i.api_data={...i.api_data??{},response:e},K(i,r.output_variable,e));break}case"script":{r.output_value!=null&&K(i,r.output_variable??i.output_variable_name,r.output_value);break}case"db_query":{r.output_value!=null&&(i.db_details={...i.db_details??{},carried_out_query:G(r.output_value)});break}case"screenshot_command":{let e=G(r.output_value);e&&typeof e=="object"&&(i.smartui_results=e);break}case"network_assertion":case"network_query":break;default:break}return i}var bt="/home/kaneai/Downloads";function N(n){return`${bt}/${n}`}function W(n){return"FILE__"+n.replace(/[^A-Za-z0-9]/g,"_")}function L(n){let t=n?.media;return!t||!t.name||!t.media_url?null:{media_id:t.media_id??"",name:t.name,media_url:t.media_url,type:t.type??"doc"}}function Z(n){return n?n.includes(`
3
- `)?n.split(`
4
- `).map(t=>t.trim()).filter(Boolean):n.split(". ").map(t=>t.trim()).filter(Boolean).map(t=>t.endsWith(".")?t:t+"."):[]}function w(n){return typeof n=="string"&&n.includes("{{secrets.")}var yt={click:"CLICK",double_click:"CLICK",type:"TYPE",fill:"TYPE",clear:"CLEAR",select:"SELECT",hover:"HOVER",drag:"DRAG_DROP",upload_files:"UPLOAD_FILE",navigate:"OPEN",go_back:"NAVIGATE",go_forward:"NAVIGATE",refresh:"REFRESH",press_key:"SENDKEYS",scroll:"SCROLL_PIXELS",scroll_into_view:"SCROLL_UNTIL_ELEMENT",wait:"WAIT",wait_until:"WAIT_UNTIL",wait_for_load:"WAIT_FOR_LOAD",switch_tab:"SWITCH_TAB",new_tab:"NEW_TAB",close_tab:"CLOSE_TAB",api:"API",evaluate_js:"EVALUATE_JS",vision_query:"VISION_QUERY",textual_query:"TEXTUAL_QUERY",get_url:"GET_URL",get_title:"GET_TITLE",assert:"ASSERTION",math:"MATHEMATICAL_OPERATION",set_cookies:"SET_COOKIES",delete_cookies:"DELETE_COOKIES",clear_cookies:"CLEAR_COOKIES",set_local_storage:"SET_LOCAL_STORAGE",delete_local_storage:"DELETE_LOCAL_STORAGE",clear_local_storage:"CLEAR_LOCAL_STORAGE",set_clipboard:"SET_CLIPBOARD",paste_clipboard:"PASTE_CLIPBOARD",clear_clipboard:"CLEAR_CLIPBOARD",device_control:"DEVICE_CONTROL",device_control_query:"DEVICE_CONTROL_QUERY"},Q={literal:"SET_VARIABLE",condition:"SET_VARIABLE",visual:"VISION_QUERY",dom:"TEXTUAL_QUERY",url:"GET_URL",title:"GET_TITLE",devtool_network:"DEVTOOLS_NETWORK_QUERY",devtool_console:"DEVTOOLS_CONSOLE_QUERY",devtool_cookies:"DEVTOOLS_COOKIES_QUERY",devtool_storage:"DEVTOOLS_STORAGE_QUERY",devtool_performance:"DEVTOOLS_PERFORMANCE",api_response:"API_CALLS_QUERY",textual_visual:"TEXTUAL_ANALYZER"},It=new Set(["CLICK","TYPE","FILL","HOVER","SCROLL_UNTIL_ELEMENT","UPLOAD_FILE","VISION_QUERY","DRAG_DROP","SELECT"]);function tt(n,t){if(n==="analyze"){let s=t?.action_params?.analyzer_type??"";return Q[s]}if(n==="scroll"&&t?.action_params?.into_view===!0)return"SCROLL_UNTIL_ELEMENT";let i=yt[n];return i||console.warn(`[migrator] UNKNOWN action_type "${n}" \u2014 falling back to "${n.toUpperCase()}"; explicit mapping required`),i??n.toUpperCase()}function et(n,t){if(!n||!t)return"";try{let i=new Date(n);return isNaN(i.getTime())?"":new Date(i.getTime()+t).toISOString()}catch{return""}}function nt(n){try{return JSON.parse(n.output_value??"{}")}catch{return{}}}function vt(n){let t=n.output_variable??"";if(!t)return"[]";let s={...nt(n)};return delete s.body,JSON.stringify([{name:t,unique_key:(n.action_id??"").replace(/-/g,"").slice(0,8)||v().replace(/-/g,"").slice(0,8),value:s,variable_description:"API Response"}])}function At(n,t,i){let s=n.action_params??{},r=It.has(t)?"Vision Agent":"Operation Agent",e={operation_type:t};if(t==="OPEN"&&(e.url=s.url??""),t==="SET_VARIABLE"&&(e.variable_name=n.output_variable??s.key??"",e.variable_value=n.output_value??""),t==="UPLOAD_FILE"){let g=L(s);g&&(e.value=N(g.name))}let o={},l={},a=n.action_instruction??"",c=s.text??"",u=s.url??"",p=[["intent",a],["value",c],["url",u]];for(let[g,h]of Object.entries(i)){let I=String(h);if(g.startsWith("secrets."))for(let[y,b]of p)b.includes(I)&&(l[y]=g);for(let[y,b]of p)b.includes(I)&&!(y in o)&&(o[y]=b)}let _=n.action_type,d={operation:n.action_instruction??"",agent:r,operation_dict:e,reasoning:_==="analyze"?s.query??"":n.intent??n.action_instruction??"",variable:o,secrets:l,params:{}};_==="analyze"&&typeof s.code=="string"&&s.code&&(d.code=s.code),_==="analyze"&&typeof s.code_js=="string"&&s.code_js&&(d.code_js=s.code_js),_==="analyze"&&typeof s.condition_expression=="string"&&s.condition_expression&&(d.condition_expression=s.condition_expression),s.uses_websocket===!0&&(d.uses_websocket=!0),s.uses_sse===!0&&(d.uses_sse=!0),_==="analyze"&&s.analyzer_type==="textual_visual"&&(typeof s.wrapped_js=="string"&&(d.wrapped_js=s.wrapped_js),Array.isArray(s.locators)&&(d.locators=s.locators),typeof s.operator=="string"&&(d.operator=s.operator),Array.isArray(s.transforms)&&(d.transforms=s.transforms),typeof s.query=="string"&&(d.query=s.query),typeof s.expected_value=="string"&&(d.expected_value=s.expected_value),typeof s.needs_unit_conversion=="boolean"&&(d.needs_unit_conversion=s.needs_unit_conversion),typeof s.condition=="string"&&(d.condition=s.condition));let m={set_cookies:"cookies",set_clipboard:"text",delete_cookies:"names",set_local_storage:"items",delete_local_storage:"keys"}[_];return m&&s[m]!==void 0&&(d[m]=s[m]),_==="set_clipboard"&&typeof s.html=="string"&&s.html&&(d.html=s.html),d}function Rt(n){let t=n.assertion_tree??{};if(typeof t.passed=="boolean")return t.passed;let i=t.sub_results??[];return i.length===0?t.status==="passed":(t.composite_operator??"and")==="or"?i.some(r=>r.passed===!0):i.every(r=>r.passed===!0)}function it(n){return n.map(t=>({description:t.description??"",store_key:t.store_key??"",expected_value:t.expected??"",extracted_value:t.extracted_value??"",operator:t.operator??"equals",transforms:t.transforms??[]}))}function Pt(n){let t=n.assertion_tree??{},i=t.sub_results??[],s=it(i);return{operator:[],assertion_operands:[],left_operand:null,right_operand:null,operands:[],sub_results:i,sub_checks:s,composite_operator:t.composite_operator??"and",verification:t.verification??"",claim:t.description??""}}function kt(n){let i=(n.action_params??{}).assertion_tree??{},s=i.sub_results??[],r=it(s);return[{operation:n.action_instruction??"",agent:"Operation Agent",operation_dict:{operation_type:"ASSERTION",assertion_tree:{sub_results:s,sub_checks:r,composite_operator:i.composite_operator??"and",verification:"",claim:i.description??n.action_instruction??"",operator:[],assertion_operands:[],left_operand:null,right_operand:null,operands:[]}},variable:{},secrets:{},params:{}}]}function xt(n,t,i,s){let r=n.visual_data;if(!r||r.x==null||r.y==null)return null;let e=t?`${t}/test_screenshots`:"";return{x:r.x,y:r.y,confidence:0,bbox:r.bbox??null,bbox_source:r.bbox?"accessibility_tree":"fallback",viewport_width:r.viewport_width??1280,viewport_height:r.viewport_height??800,scale_factor:null,raw_image_url:e?`${e}/untagged_screenshot/${i}.${s?.get(i)??"png"}`:"",raw_image_sas_url:"",annotated_image_url:"",annotated_image_sas_url:""}}function Ot(n){if(!n)return"";let t=n;return typeof n=="object"&&!Array.isArray(n)&&Array.isArray(n.frameInfo)&&(t=n.frameInfo),!Array.isArray(t)||t.length===0?"":JSON.stringify(t)}function St(n){return/^(android|ios)_native$/i.test(n.platform??"")}function st(n,t){return n.map(i=>({...i,type:t?i.strategy??i.type??"native":i.isXPath?"xpath":"css"}))}function Nt(n,t,i){let s={selector_target:"",drag_displacement:{},hold_duration_ms:null,move_duration_ms:null,hold_at_destination_ms:null};if(n!=="drag")return s;let r=t.target_selectors,e={};typeof t.direction=="string"&&t.direction&&(e.direction=t.direction,typeof t.fraction=="number"&&(e.fraction=t.fraction));let o=l=>typeof t[l]=="number"?Math.trunc(t[l]):null;return{selector_target:Array.isArray(r)&&r.length>0?st(r,i):"",drag_displacement:e,hold_duration_ms:o("hold_duration_ms"),move_duration_ms:o("move_duration_ms"),hold_at_destination_ms:o("hold_at_destination_ms")}}function X(n,t="",i){let s=n.action_type,r=tt(s,n),e=n.action_params??{},o=n.coordinates??null,l=n.selectors??null,a=!!(l&&l.length>0),c=St(n),u=Nt(s,e,c),p=n.timestamp??"",_=n.duration_ms??0,d=n.variables_used??{},f=n.action_id??v(),m=v(),g=et(p,_),h="",I="";if(s==="navigate")I=e.url??"",h=I;else if(s==="type"||s==="fill")h=e.text??"";else if(s==="press_key")h=e.key??"";else if(s==="wait")h=String(e.ms??e.timeout_ms??"");else if(s==="evaluate_js")h=e.script??"";else if(s==="upload_files"){let U=L(e);U&&(h=N(U.name))}else s==="analyze"&&r==="SET_VARIABLE"&&(h=n.output_value??"");let y="";s==="go_back"?y="back":s==="go_forward"&&(y="forward");let b=n.action_instruction??"",A=w(h)||w(I)||w(b),S=At(n,r,d);return{operation_id:f,instruction_id:m,instruction:b,intent:b,operation_start:p,operation_end:g,status:n.status??"",command:r,name:"",target:"",value:h,message:"",operation_dict:"",frame:Ot(n.frame_info),error_message:n.error??"",code_snippet:"",sub_instruction_obj:JSON.stringify(S),test_id:"",test_version:"",action:"",string_to_float:!1,feedback_msg:"",time_taken:"",create_time_stamp:"",update_time_stamp:"",locator_variable:"",locator_variable_name:"",image_url:t?`${t}/test_screenshots/untagged_screenshot/${f}.${i?.get(f)??"png"}`:"",alternative_xpaths:[],attribute:"",value_description:"",url:I,navigation_direction:y,tagified_image_url:"",query_variable_name:n.output_variable??"",query_variable_value:n.output_value??"",query_variable_type:"",expected_value:"",queried_value:"",operator:"",assertion_status:r==="ASSERTION"?Rt(e):"",query_info_dict:{},query_content_confidence:"none",debugging_logs:[],locator_index:0,query_html:"",user_variables:"[]",optional_flag:!1,max_retries:0,retries_delay:0,explicit_wait:0,implicit_wait:0,tab_index:String(e.tab_index??""),tab_identifier:String(e.tab_identifier??""),scroll_value:e.amount??1,scroll_direction:e.direction??"",mi_scroll_payload:{},sleep_duration:0,app_id:"",manual_interaction_tag:"",string_to_float_list:[],js_snippet:s==="evaluate_js"?e.script??"":"",code_error:"",hide:A,dismiss_dialog:!1,use_v2_mobile_tagging:c,multiple_inputs:!1,dialog_action:"",dialog_type:"",is_coordinates_used_for_interaction:o!==null&&!a,element_coordinates_ratio:[],element_bounds_ratio:[],x_coord:a?null:o?.x??null,y_coord:a?null:o?.y??null,target_x_coord:e.target_x??null,target_y_coord:e.target_y??null,source_description:e.source_description??null,target_description:e.target_description??null,use_coordinates:o!==null&&!a,kaneaiMobileTaggingImageLimit:1,clicks_order_code:"se_js_ac",selector:a?st(l,c):"",selector_target:u.selector_target,math_result_variable_name:"",math_result_variable_value:"",expression_tree:r==="ASSERTION"?Pt(e):e.expression_tree??{},assertion_tree:e.assertion_tree??{},assertion_tree_simplified:{},network_throttle:{},is_mobile_offline:!1,autoheal:!1,reprobe:n.reprobe??!1,click_modifier:(e.click_count??1)>=2?{kind:"multi_click",frequency:e.click_count}:null,db_query:"",db_details:{},db_query_decoded:"",is_global_variable:!1,is_global_variable_persist:!1,global_variable_id:"",wait_for_element_timeout:0,failure_condition:r==="ASSERTION"?"Fail test immediately":"",screenshot_command:"",smartui_contents:{},smartui_results:{},result_type:"",result_hint:"",drag_offset:{},drag_displacement:u.drag_displacement,hold_duration_ms:u.hold_duration_ms,move_duration_ms:u.move_duration_ms,hold_at_destination_ms:u.hold_at_destination_ms,start_coordinates:e.source_coordinates?{x:e.source_coordinates[0],y:e.source_coordinates[1]}:{},end_coordinates:e.target_coordinates?{x:e.target_coordinates[0],y:e.target_coordinates[1]}:{},element_rect:null,is_canvas:!1,until_condition:"",until_max_retries:0,until_settle_ms:0,api_data:s==="api"?{request:n.action_params?.api_data?.request??{}}:{},output_variables:s==="api"?n.output_variable?{[n.output_variable]:null}:{}:n.output_variable?{[n.output_variable]:n.output_value??""}:{},visual_context:xt(n,t,f,i),reasoning:s==="analyze"?e.query??"":n.intent??n.action_instruction??""}}function Y(n,t){let i=n.action_type,s=tt(i,n),r=n.timestamp??"",e=n.duration_ms??0,o=et(r,e),l=s==="ASSERTION"||s==="MATHEMATICAL_OPERATION";return{instruction_id:t.instruction_id,instruction_class:l?"non_driver_action":"driver_action",module_id:"",instruction:n.action_instruction??"",command:s,error:null,parent_instruction_id:"",classification_layer_resp:s==="ASSERTION"?kt(n):[],classification_error:{},operations:[t],status:n.status??"",start_timestamp:r,end_timestamp:o,type:"agent_generated",tags:[],html_paths:[],optional_flag:!1,max_retries:0,retries_delay:0,explicit_wait:0,implicit_wait:0,content_type:i==="api"?"api":i==="analyze"&&n.action_params?.analyzer_type==="api_response"?"api_calls_query":i==="analyze"&&n.action_params?.analyzer_type?.startsWith("devtool_")?n.action_params.analyzer_type.replace("devtool_","devtools_"):"instruction",js_snippet:i==="evaluate_js"?n.action_params?.script??"":"",user_variables:i==="api"?vt(n):"[]",api_data:i==="api"?{request:n.action_params?.api_data?.request??{},response:nt(n)}:{},params_used:!1,hard_assertion:s==="ASSERTION"?n.action_params?.failure_condition==="hard":!1,expected_outcome:"",module_execution_index:0,module_version:null,network_throttle:{},isEdited:!1,use_query_assertion_v2:!1,db_query:"",db_details:{},network_assertion_content:{},screenshot_command:"",smartui_contents:{},generative_id:"",plan_id:"",generative_objective:"",error_message:"",error_code:"",reason:"",title:"",used_variables:[],reasoning:i==="analyze"?n.action_params?.query??"":n.intent??n.action_instruction??""}}function Lt(n,t=[]){let i=n.action_params??{},s=i.branches??[],r=i.winning_index??-1,e=i.sub_results??[],o={};for(let a of e){let c=a.sub_results;if(c)for(let u of c){let p=u.store_key;p&&(o[p]=u)}}let l=s.map((a,c)=>{let u=c===r,p=(a.sub_checks??[]).map(_=>{let d=o[_.store_key];return{description:_.description,store_key:_.store_key,expected_value:_.expected_value,stored_value:d?.extracted_value??_.stored_value,operator:_.operator??d?.operator??"equals",transforms:_.transforms??d?.transforms??[]}});if(p.length===0&&a.condition&&e.length>0){let d=e.find(f=>f.branch_index===c)?.sub_results??[];d.length>0&&(p=d.map(f=>({description:f.description??a.condition,store_key:f.store_key??"",expected_value:f.expected??"true",stored_value:f.extracted_value??void 0,operator:f.operator??"equals",transforms:f.transforms??[]})))}return{branch_index:c,condition:a.condition??null,branch_type:a.branch_type??"sub_objective",passed:u,sub_objective:null,custom_event:a.custom_event??null,children:u?t:[],sub_checks:a.condition?p:[],composite_operator:a.composite_operator??"and"}});return{content_type:"conditional_block",instruction_id:`if_else_${v().slice(0,8)}`,instruction:n.action_instruction??"",instruction_class:"driver_action",command:"",status:n.status??"success",resolved_branch_index:r,branches:l,generative_id:"",generative_objective:"",variables_used:{},classification_layer_resp:[],classification_error:{},used_variables:[],user_variables:"[]",module_id:"",module_execution_index:0,module_version:"",plan_id:"",optional_flag:!1,max_retries:0,retries_delay:0,explicit_wait:0,implicit_wait:0,error:null,error_message:"",error_code:"",reason:"",start_timestamp:n.timestamp??"",end_timestamp:"",type:"agent_generated",hook:null,hook_type:null,evaluation_context:{},query_variables:{}}}function rt(n,t,i){for(let s of n)s.content_type==="instruction"&&"generative_id"in s&&(s.generative_id=t,s.generative_objective=i)}function T(n,t="",i,s){let r=[],e=0;for(;e<n.length;){let o=n[e],l=o.action_type;if(!s?.keepFailedActions&&o.status==="error"&&l!=="assert"&&l!=="if_else"&&l!=="child_agent_start"&&l!=="child_agent_end"&&!(o.until_condition&&!o.error)){e+=1;continue}if(l==="analyze"&&(!Q[o.action_params?.analyzer_type??""]||o.action_params?.analyzer_type==="textual_visual"&&o.action_params?.code)){e+=1;continue}if(l==="child_agent_start"){let a=o.action_params?.child_id??"",c=o.action_params?.objective??"",u=[];e+=1;let p=1,_="error",d;for(;e<n.length&&p>0;){let A=n[e],S=A.action_type;if(S==="child_agent_start")p+=1;else if(S==="child_agent_end"&&(p-=1,p===0)){_=A.status??"success",d=A,e+=1;break}p>0&&u.push(A),e+=1}let f=T(u,t,i);rt(f,a,c);let m=d?.action_params?.result_code??null,g=d?.action_params?.reason_code??null,h=d?.action_params?.error_message??null,I=d?.action_params?.summary??null,y=d?.action_params?.one_liner??null,b=_==="error";r.push({content_type:"generative_block",instruction_id:`generative_block_${a}`,generative_id:a,objective:c,status:_,children:f,error_message:b?h??null:null,error_code:b?g??null:null,result_code:m??null,bifurcation_context:[],approach_reason:Z(I),one_liner:y??null});continue}else if(l==="child_agent_end"){e+=1;continue}else if(l==="if_else"){e+=1;let a=[];for(;e<n.length&&n[e].action_type==="child_agent_start";){let c=n[e],u=c.action_params?.child_id??"",p=c.action_params?.objective??"",_=[];e+=1;let d=1,f="error";for(;e<n.length&&d>0;){let g=n[e];if(g.action_type==="child_agent_start")d+=1;else if(g.action_type==="child_agent_end"&&(d-=1,d===0)){f=g.status??"success",e+=1;break}d>0&&_.push(g),e+=1}let m=T(_,t,i);a.push(...m)}r.push(Lt(o,a));continue}else if(l==="query_tool"){e+=1;continue}else if(o.until_condition){let a=X(o,t,i),c=Y(o,a),u=typeof o.until_condition_met=="boolean"?o.until_condition_met:o.status==="success";r.push({content_type:"until_block",instruction_id:`until_${v().slice(0,8)}`,condition:o.until_condition,max_retries:o.until_max_retries??10,settle_ms:o.until_settle_ms??500,current_count:0,condition_met:u,children:[c],generative_id:"",generative_objective:"",variables_used:{},status:o.status??"success"})}else{let a=X(o,t,i),c=Y(o,a);r.push(c)}e+=1}return r}function k(n,t="",i,s){let r=[],e=[],o=s?.passthrough,l=o?H(o.authoredInstructions):null;for(let c of n){if(o&&l&&c.flatIndex!==void 0&&o.replayOnlyFlatIndices.has(c.flatIndex)){let g=J(c.records,l);if(g){for(let h of g)r.push(h),e.push(c.flatIndex);continue}console.warn(`[migrator] replay-only passthrough: no authored operation matched step ${c.flatIndex} (action_id \u2260 any operation_id in the authored blob) \u2014 falling back to this run's records`)}let u=T(c.records,t,i,s);if(u.length===0)continue;let p=v().replace(/-/g,"");rt(u,p,c.objective);let _=u.some(g=>"status"in g&&typeof g.status=="string"?g.status==="error"||g.status==="failed":!1),d=c.resultCode?parseInt(c.resultCode,10):null,f=d!==null&&!isNaN(d)&&d>=200,m=_||f?"error":"success";r.push({content_type:"generative_block",instruction_id:`generative_block_${p}`,generative_id:p,objective:c.objective,status:m,children:u,error_message:m==="error"?c.errorMessage??null:null,error_code:m==="error"?c.reasonCode??null:null,result_code:c.resultCode??null,bifurcation_context:[],approach_reason:Z(c.summary),one_liner:c.oneLiner??null}),e.push(c.flatIndex)}let a=s?.moduleSpans??[];return a.length===0?{instructions:r}:{instructions:ot(r.map((c,u)=>({block:c,flat:e[u]})),a)}}function ot(n,t){let i=[],s=e=>e===void 0?void 0:t.find(o=>e>=o.flatFrom&&e<=o.flatTo),r=0;for(;r<n.length;){let e=s(n[r].flat);if(!e){i.push(n[r].block),r++;continue}let o=[];for(;r<n.length&&s(n[r].flat)===e;)o.push(n[r++]);i.push(Tt(e,ot(o,e.children)))}return i}function wt(n){for(let t of n){let i="status"in t&&typeof t.status=="string"?t.status:"";if(i==="error"||i==="failed"){let s="error_message"in t?t.error_message:void 0,r="error_code"in t?t.error_code:void 0;return{message:s??null,code:r??null}}}return null}function Tt(n,t){let i=n.meta,s=(c,u="")=>typeof i[c]=="string"?i[c]:u,r=(c,u=!1)=>typeof i[c]=="boolean"?i[c]:u,e=c=>Array.isArray(i[c])?i[c]:[],o=typeof i.module_version=="number"||typeof i.module_version=="string"?i.module_version:null,l=s("module_id"),a=wt(t);return{content_type:V,instruction_id:`module_block_${l}`,module_id:l,module_version:o,module_instance_id:v(),module_name:s("module_name"),module_description:s("module_description"),module_platform:s("module_platform"),creation_mode:s("creation_mode","Agent"),tms_status:s("tms_status","active"),is_validated:r("is_validated"),is_dirty:n.dirty,enrichment_id:s("enrichment_id"),tags:e("tags"),project_ids:e("project_ids"),link_to_all:r("link_to_all"),status:a?"error":"success",children:t,error_message:a?.message??null,error_code:a?.code??null,update_available:!1,update_info:{}}}function ct(n,t){let i;try{i=at(n)}catch{return 0}let s=0,r=i.filter(e=>/^\d+$/.test(e)).sort((e,o)=>Number(e)-Number(o));for(let e of r){let o=x(n,e),l=x(o,"logs");if(!Ct(l))continue;let a;try{a=at(l)}catch{continue}let c=a.filter(_=>_.endsWith("-actions.ndjson")).sort((_,d)=>(parseInt(_,10)||0)-(parseInt(d,10)||0)),u=[];for(let _ of c){let d=t.readActions(x(l,_));d.length&&u.push({objective:t.objective??"",records:d})}if(u.length===0)continue;let{instructions:p}=k(u,t.screenshotBaseUrl??"",t.extMap,{keepFailedActions:!0});if(p.length!==0)try{let _=x(o,"auteur");jt(_,{recursive:!0}),Dt(x(_,"execution.json"),JSON.stringify(t.buildBlob(p),null,2)),s++,t.log?.("info","EVIDENCE_ARCHIVED_ATTEMPT_BLOB","Derived nested attempt blob",{attempt:e,instructions:p.length})}catch(_){t.log?.("debug","EVIDENCE_ARCHIVED_ATTEMPT_BLOB_FAILED","Nested attempt blob derivation failed",{attempt:e,error:_ instanceof Error?_.message:String(_)})}}return s}var lt=gt(ft(),1);import{createWriteStream as Ut}from"fs";import{readFile as Ft}from"fs/promises";import{join as Mt,basename as Bt}from"path";import{tmpdir as zt}from"os";var Vt=["**/screenshots/**","**/annotated/**","**/tcg/**","**/bifurcation/**"];async function ut(n){let t=Mt(zt(),`${Bt(n)}_artifacts.zip`);return new Promise((i,s)=>{let r=Ut(t),e=(0,lt.default)("zip",{zlib:{level:6}});r.on("close",()=>i(t)),e.on("error",s),e.pipe(r),e.glob("**/*",{cwd:n,ignore:Vt}),e.finalize()})}async function dt(n){return Ft(n)}async function Gt(n,t){return pt(z(n,t))}function Kt(n){return{key:"artifacts",content_type:"application/zip",filename:`${n}.evidence`}}var _t=class{config;controller;testId;constructor(t){this.config=t,this.controller=new M(t.controllerBaseUrl,t.auth),this.testId=t.testId}log(t,i,s,r){this.config.log?.(t,i,s,r)}async execute(){let{onProgress:t}=this.config;try{if(!this.testId)return this.log("error","PIPELINE_ABORT","No test_id available"),{success:!1,testId:null,error:"No test_id available"};let i=this.config.evidence,s=null;if(this.config.shouldUploadArtifacts!==!1){t("convert","running");let l=this.collectNdjsonPerRun(),a=l.reduce((m,g)=>m+g.records.length,0);this.log("info","PIPELINE_CONVERT","Collected NDJSON records",{total_records:a,run_groups:l.length});let c=this.loadReplayOnlyPassthrough(),{instructions:u}=l.length>0?k(l,this.config.screenshotBaseUrl??"",this.config.screenshotExtMap,{moduleSpans:this.config.moduleSpans,...c?{passthrough:c}:{}}):{instructions:[]};this.log("info","PIPELINE_CONVERT_INSTRUCTIONS","Auteur instructions produced",{count:u.length});let p=this.buildExecutionEnvelope(u),_=Buffer.from(JSON.stringify(p));this.log("info","PIPELINE_CONVERT_BLOB","Blob created",{size_kb:+(_.length/1024).toFixed(1)});let d=E(this.config.sessionDir,"execution.json");O(d,JSON.stringify(p,null,2)),this.log("info","PIPELINE_CONVERT_LOCAL_SAVE","Execution blob saved locally",{path:d});let f=i?.packTestDir??this.config.evidenceRead?.packTestDir;if(f){let m=E(f,"auteur");D(m,{recursive:!0}),O(E(m,"execution.json"),JSON.stringify(p,null,2)),this.log("info","PIPELINE_CONVERT_PACK_COPY","Execution blob copied into pack",{path:E(m,"execution.json")}),this.deriveArchivedAttemptBlobs(f)}if(t("convert","done"),i)s=_;else{t("zip","running"),this.log("info","PIPELINE_ZIP_START","Zipping session",{session_dir:this.config.sessionDir});let m=null,g;try{m=await ut(this.config.sessionDir),g=await dt(m),this.log("info","PIPELINE_ZIP_DONE","Zip complete",{size_mb:+(g.length/1024/1024).toFixed(1),path:m}),t("zip","done",`${(g.length/1024/1024).toFixed(1)}MB`)}finally{m&&await $t(m).catch(()=>{})}t("presign","running"),this.log("info","PIPELINE_PRESIGN_START","Requesting presigned URLs",{url:`${this.config.controllerBaseUrl}/upload/presign`,test_id:this.testId,session_id:this.config.sessionId});let h=await this.controller.getPresignedUrls(this.testId,this.config.sessionId,[{key:"artifacts",content_type:"application/zip",filename:`${this.config.sessionId}_artifacts.zip`},{key:"blob",content_type:"application/json",filename:`${this.config.commitId}.json`}]);this.log("info","PIPELINE_PRESIGN_OK","Presigned URLs received",{artifacts_url:h.urls.artifacts?.blob_url,blob_url:h.urls.blob?.blob_url}),t("presign","done"),t("upload","running"),this.log("info","PIPELINE_UPLOAD_START","Uploading artifacts and blob",{artifact_size_mb:+(g.length/1024/1024).toFixed(1),blob_size_kb:+(_.length/1024).toFixed(1)}),await Promise.all([R(h.urls.artifacts.upload_url,g,"application/zip"),R(h.urls.blob.upload_url,_,"application/json")]),this.log("info","PIPELINE_UPLOAD_OK","Upload complete"),t("upload","done")}}else{let l=this.collectNdjsonPerRun(),a=this.loadReplayOnlyPassthrough(),{instructions:c}=l.length>0?k(l,this.config.screenshotBaseUrl??"",this.config.screenshotExtMap,{keepFailedActions:!0,moduleSpans:this.config.moduleSpans,...a?{passthrough:a}:{}}):{instructions:[]},u=this.buildExecutionEnvelope(c),p=E(this.config.sessionDir,"execution.json");O(p,JSON.stringify(u,null,2)),this.log("info","PIPELINE_LOCAL_SAVE","Execution blob saved locally (no upload)",{path:p});let _=this.config.evidence?.packTestDir??this.config.evidenceRead?.packTestDir;if(_){let d=E(_,"auteur");D(d,{recursive:!0});let f=this.readAuthoredExecution();O(E(d,"execution.json"),f??JSON.stringify(u,null,2)),this.log("info","PIPELINE_CONVERT_PACK_COPY","Execution blob copied into pack (gated)",{path:E(d,"execution.json"),source:f?"authored":"run_envelope"}),this.deriveArchivedAttemptBlobs(_)}t("convert","skipped"),t("zip","skipped"),t("presign","skipped"),t("upload","skipped"),this.log("info","PIPELINE_UPLOAD_SKIPPED","Upload steps skipped (gate disabled)")}if(this.config.shouldReplaceLocalOutput&&this.config.onAtomicReplace){t("atomic_replace","running");try{await this.config.onAtomicReplace(),this.log("info","PIPELINE_ATOMIC_REPLACE_OK","Local output replaced"),t("atomic_replace","done")}catch(l){let a=l instanceof Error?l.message:String(l);throw this.log("error","PIPELINE_ATOMIC_REPLACE_FAILED","Atomic-replace failed",{error:a}),t("atomic_replace","failed",a),l}}else t("atomic_replace","skipped");let r,e;if(this.config.shouldCommit&&!this.config.isFirstRun&&this.config.onCommitLock){t("commit_lock","running");let l=await this.config.onCommitLock();if(l.ok)r=l.testcaseId||void 0,this.log("info","PIPELINE_COMMIT_LOCK_OK","Commit lock acquired",{testcase_id:r??"none",trigger:l.trigger??null,test_instance_id:l.testInstanceId??null}),t("commit_lock","done");else return this.log("error","PIPELINE_COMMIT_LOCK_FAILED","Commit lock failed",{reason:l.reason,message:l.message}),t("commit_lock","failed",`${l.reason??"unknown"}: ${l.message??""}`),{success:!1,testId:this.testId,error:`commit-lock failed: ${l.reason??"unknown"}`}}else t("commit_lock","skipped");if(this.config.isFirstRun&&!this.config.skipTmsFinalize){t("finalize","running"),this.log("info","PIPELINE_FINALIZE_START","Finalizing test (first-run)",{test_id:this.testId,commit_id:this.config.commitId});let l=new B(this.config.tmsBaseUrl,this.config.tmsUsername,this.config.tmsAccessKey),a=this.config.runObjectives&&this.config.runObjectives.length>0?this.config.runObjectives:[this.config.firstObjective];if(r=(await l.endTest(this.testId,{commit_id:this.config.commitId,time_taken:Math.round(this.config.totalDuration),steps_count:this.config.totalSteps,commit_message:this.config.firstObjective.slice(0,255),objectives:a})).testcase_id||void 0,this.log("info","PIPELINE_FINALIZE_OK","Test finalized",{testcase_id:r??"none"}),this.config.onFinalizeSuccess)try{await this.config.onFinalizeSuccess(r)}catch(u){this.log("warn","PIPELINE_FINALIZE_META_FAILED","Meta-rewrite after endTest failed",{error:String(u)})}t("finalize","done")}else t("finalize","skipped"),this.log("info","PIPELINE_FINALIZE_SKIPPED","Finalize skipped (evolve flow or first-run disabled)");if(r&&this.config.shareApiBaseUrl)try{e=await this.generateShareLink(r),this.log("info","PIPELINE_SHARE_OK","Share link generated",{share_id:e})}catch(l){this.log("warn","PIPELINE_SHARE_FAILED","Share link failed",{error:String(l)})}if(i&&s){let l=null;t("zip","running");try{await i.sealFn({testcaseId:r,shareId:e}),l=i.sealedPackPath?await pt(i.sealedPackPath):await Gt(i.executionId,i.cwd),this.log("info","PIPELINE_EVIDENCE_SEALED","Evidence pack sealed",{execution_id:i.executionId}),this.log("info","PIPELINE_PACK_READ","Sealed pack read",{size_mb:+(l.length/1024/1024).toFixed(1)})}catch(a){let c=a instanceof Error?a.message:String(a);this.log("warn","PIPELINE_EVIDENCE_UPLOAD_SKIPPED","Evidence seal/read failed \u2014 uploading blob only",{execution_id:i.executionId,error:c})}if(l){t("zip","done",`${(l.length/1024/1024).toFixed(1)}MB`),t("presign","running");let a=await this.controller.getPresignedUrls(this.testId,this.config.sessionId,[Kt(i.executionId),{key:"blob",content_type:"application/json",filename:`${this.config.commitId}.json`}]);this.log("info","PIPELINE_PRESIGN_OK","Presigned URLs received",{artifacts_url:a.urls.artifacts?.blob_url,blob_url:a.urls.blob?.blob_url}),t("presign","done"),t("upload","running"),this.log("info","PIPELINE_UPLOAD_START","Uploading pack and blob",{artifact_size_mb:+(l.length/1024/1024).toFixed(1),blob_size_kb:+(s.length/1024).toFixed(1)}),await Promise.all([R(a.urls.artifacts.upload_url,l,"application/zip"),R(a.urls.blob.upload_url,s,"application/json")]),this.log("info","PIPELINE_UPLOAD_OK","Upload complete"),t("upload","done")}else{t("zip","skipped"),t("presign","running");let a=await this.controller.getPresignedUrls(this.testId,this.config.sessionId,[{key:"blob",content_type:"application/json",filename:`${this.config.commitId}.json`}]);t("presign","done"),t("upload","running"),this.log("info","PIPELINE_UPLOAD_START","Uploading blob only (evidence skipped)",{blob_size_kb:+(s.length/1024).toFixed(1)}),await R(a.urls.blob.upload_url,s,"application/json"),this.log("info","PIPELINE_UPLOAD_OK","Blob upload complete (pack skipped)"),t("upload","done")}}let o;if(this.config.codeExport?.enabled&&r){let l=!1;try{await this.triggerCodeExport(r),this.log("info","PIPELINE_CODE_EXPORT_START","Code export triggered"),l=!0}catch(a){let c=a instanceof Error?a.message:String(a);this.log("error","PIPELINE_CODE_EXPORT_FAILED","Code export trigger failed; skipping poll",{error:c}),t("code_export","failed",`trigger failed: ${c}`)}if(l){t("code_export","running","Waiting for code generation\u2026");try{o=await this.pollAndDownloadCode(r,t),this.log("info","PIPELINE_CODE_EXPORT_OK","Code export complete",{dir:o}),t("code_export","done",o)}catch(a){let c=a instanceof Error?a.message:String(a);this.log("error","PIPELINE_CODE_EXPORT_FAILED","Code export failed",{error:c}),t("code_export","failed",c)}}}else t("code_export","skipped");return this.log("info","PIPELINE_COMPLETE","Pipeline complete"),{success:!0,testId:this.testId,testcaseId:r,shareId:e,codeExportDir:o}}catch(i){return{success:!1,testId:this.testId,error:i instanceof Error?i.message:String(i)}}}async runCodeExport(t,i){let s=i??this.config.onProgress,r=!1;try{await this.triggerCodeExport(t),this.log("info","PIPELINE_CODE_EXPORT_TRIGGER","Code export triggered",{testcase_id:t}),r=!0}catch(e){let o=e instanceof Error?e.message:String(e);this.log("error","PIPELINE_CODE_EXPORT_TRIGGER_FAILED","Code export trigger failed; skipping poll",{error:o}),s("code_export","failed",`trigger failed: ${o}`)}if(r){s("code_export","running","Waiting for code generation\u2026");try{let e=await this.pollAndDownloadCode(t,s);return this.log("info","PIPELINE_CODE_EXPORT_OK","Code export complete",{dir:e}),s("code_export","done",e),e}catch(e){let o=e instanceof Error?e.message:String(e);this.log("error","PIPELINE_CODE_EXPORT_FAILED","Code export failed",{error:o}),s("code_export","failed",o);return}}}deriveArchivedAttemptBlobs(t){try{let i=ct(t,{readActions:s=>this.readNdjsonFromFile(s),buildBlob:s=>this.buildExecutionEnvelope(s),objective:this.config.firstObjective,screenshotBaseUrl:this.config.screenshotBaseUrl??"",extMap:this.config.screenshotExtMap,log:(s,r,e,o)=>this.log(s,r,e,o)});i>0&&this.log("info","PIPELINE_ARCHIVED_ATTEMPTS","Nested retry-attempt blobs derived",{count:i})}catch(i){this.log("debug","PIPELINE_ARCHIVED_ATTEMPTS_FAILED","Nested attempt blob pass failed",{error:i instanceof Error?i.message:String(i)})}}collectNdjsonPerRun(){let t=[],i=this.config.runObjectives??[],s=this.config.runMetadata??[],r=this.config.evidence??this.config.evidenceRead;for(let e=0;e<this.config.runDirs.length;e++){let o=this.config.runDirs[e],l=i[e]||this.config.firstObjective,a=s[e],c=r?this.readNdjsonFromFile(E(r.packTestDir,"logs",`${r.runIndices?.[e]??e}-actions.ndjson`)):this.readNdjsonFromDir(o);if(c.length>0){let u=r?.runIndices?.[e]??e,p=this.config.runFlatIndex?.[u];t.push({objective:l,records:c,...p!==void 0?{flatIndex:p}:{},resultCode:a?.resultCode,reasonCode:a?.reasonCode,errorMessage:a?.errorMessage,summary:a?.summary,oneLiner:a?.oneLiner})}}if(t.length===0){let e=E(this.config.sessionDir,"runs");if(j(e))try{let l=qt(e,{withFileTypes:!0}).filter(a=>a.isDirectory()).map(a=>a.name).sort();for(let a of l){let c=E(e,a),u=this.readNdjsonFromDir(c);u.length>0&&t.push({objective:this.config.firstObjective,records:u})}}catch{}}return t}readNdjsonFromDir(t){let i=[E(t,"run-test","actions.ndjson"),E(t,"actions.ndjson")];for(let s of i)if(j(s))return this.readNdjsonFromFile(s);return[]}readNdjsonFromFile(t){let i=[];if(!j(t))return i;this.log("debug","PIPELINE_COLLECT_READ","Reading NDJSON file",{path:t});let s=C(t,"utf-8");for(let r of s.split(`
5
- `)){let e=r.trim();if(e)try{i.push(JSON.parse(e))}catch{}}return i}async generateShareLink(t){let i=`${this.config.shareApiBaseUrl}/lshs/api/v1.0/share-item/generate-sharable-link`;this.log("info","PIPELINE_SHARE_START","Requesting share link",{url:i,testcase_id:t});let s={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({entityIds:[t],entityType:"Test Case Details",expiresAt:7})},r=!!this.config.authResolver;this.log("debug","PIPELINE_SHARE_AUTH","Share link auth config",{resolver:r,fallback_auth_type:typeof this.config.auth=="string"?"bearer":"basic",tms_user:this.config.tmsUsername});let e=r?await this.config.authResolver.fetch(i,s):await P(i,{...s,headers:{...s.headers,Authorization:this.buildAuthHeader()}});if(!e.ok)throw new Error(`Share link API failed: ${e.status} ${await e.text()}`);let o=await e.json();if(!o.shareId)throw new Error("Share link API returned no shareId");return o.shareId}async triggerCodeExport(t){if(!this.config.codeExport)throw new Error("triggerCodeExport called without resolved codeExport config");let{url:i,body:s}=q({tmsBaseUrl:this.config.tmsBaseUrl,testcaseId:t,codeExport:this.config.codeExport,mobile:this.config.mobile});this.log("info","PIPELINE_CODE_EXPORT_POST","Triggering code export",{url:i});let r={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(s)},e=this.config.authResolver?await this.config.authResolver.fetch(i,r):await P(i,{...r,headers:{...r.headers,Authorization:this.buildAuthHeader()}});if(!e.ok)throw new Error(`Code export failed: ${e.status} ${await e.text()}`)}async pollAndDownloadCode(t,i){let s=$({tmsBaseUrl:this.config.tmsBaseUrl,testcaseId:t}),r=this.config.exitTimeoutMs??3e5,e=5e3,o=Date.now()+r;this.log("info","PIPELINE_CODE_EXPORT_POLL","Polling for code export",{url:s,timeout_ms:r});let l=(a,c)=>this.config.authResolver?this.config.authResolver.fetch(a,c):P(a,{...c,headers:{...c?.headers,Authorization:this.buildAuthHeader()}});for(;Date.now()<o;){let a=await l(s,{method:"GET",headers:{Accept:"application/json"}});if(!a.ok){let d=await a.text().catch(()=>"");throw this.log("warn","PIPELINE_CODE_EXPORT_POLL_FAILED","Code export poll non-200; skipping",{status:a.status,body:d.slice(0,200)}),new Error(`code export poll skipped: HTTP ${a.status}`)}let u=(await a.json()).data?.find(d=>d.code_name==="kane-cli-trigger");if(!u){this.log("debug","PIPELINE_CODE_EXPORT_WAITING","No kane-cli-trigger entry yet"),i("code_export","running","Waiting for code generation\u2026"),await this.sleep(e);continue}let p=u.status.toLowerCase();if(p==="in progress"||p==="in_progress"||p==="pending"){this.log("debug","PIPELINE_CODE_EXPORT_IN_PROGRESS","Code export in progress",{status:u.status}),i("code_export","running","Generating code\u2026"),await this.sleep(e);continue}if(!u.url||u.url.length===0)throw new Error(`Code export status=${u.status} but no files returned`);let _=this.config.codeExportDir??E(this.config.sessionDir,"code-export");D(_,{recursive:!0}),this.log("info","PIPELINE_CODE_EXPORT_DOWNLOAD","Downloading code files",{file_count:u.url.length,dir:_}),i("code_export","running",`Downloading ${u.url.length} files\u2026`);for(let d of u.url){let f=E(_,d.file_name),m=await P(d.file_url);if(!m.ok){this.log("warn","PIPELINE_CODE_EXPORT_FILE_FAILED","Failed to download file",{file_name:d.file_name,status:m.status});continue}let g=await m.text();O(f,g,"utf-8"),this.log("info","PIPELINE_CODE_EXPORT_FILE_SAVED","File saved",{file_name:d.file_name,size_bytes:g.length})}return _}throw new Error("Code export timed out")}sleep(t){return new Promise(i=>setTimeout(i,t))}buildAuthHeader(){return typeof this.config.auth=="string"?`Bearer ${this.config.auth}`:F(this.config.auth.username,this.config.auth.accessKey)}readAuthoredExecution(){let t=this.config.authoredExecutionPath;if(!t)return null;try{let i=C(t,"utf8");return JSON.parse(i),i}catch{return this.log("warn","PIPELINE_AUTHORED_BLOB_UNREADABLE","Authored execution.json missing/unreadable \u2014 pack gets this run's envelope",{path:t}),null}}loadReplayOnlyPassthrough(){let t=this.config.replayOnlyPassthrough;if(!(!t||t.flatIndices.length===0))try{let i=JSON.parse(C(t.authoredExecutionPath,"utf8"));if(!Array.isArray(i.instructions))throw new Error("no instructions array");return{authoredInstructions:i.instructions,replayOnlyFlatIndices:new Set(t.flatIndices)}}catch(i){this.log("warn","PIPELINE_PASSTHROUGH_BLOB_UNREADABLE","Authored execution.json missing/unreadable \u2014 replay-only steps convert from this run's records",{path:t.authoredExecutionPath,flat_indices:t.flatIndices,error:i instanceof Error?i.message:String(i)});return}}buildExecutionEnvelope(t){let i=this.config.runStatuses.every(c=>c==="passed")?"success":"error",s=this.config.variableIds??{},r=[];if(this.config.variables)for(let[c,u]of Object.entries(this.config.variables)){if(u.secret)continue;let p=c.startsWith("global.")?c.slice(7):c;r.push({id:s[p]??0,name:p,value:u.value,session_value:u.value,is_persist:!1,environment_id:0,environment_name:"No Env"})}let e=[],o=c=>{let u=e.find(p=>p.name===c.name);u?u.value=c.value:e.push(c)},l=[],a=new Set;for(let c of this.collectNdjsonPerRun())for(let u of c.records)if(u.output_variable&&u.output_value!=null&&o({name:u.output_variable,value:String(u.output_value),value_type:"test_level",variable_description:"ANALYZE result"}),u.action_type==="upload_files"){let p=L(u.action_params);if(p){let _=p.media_id||p.media_url;if(!a.has(_)){a.add(_),l.push({media_url:p.media_url,media_id:p.media_id,name:p.name,type:p.type});let d=N(p.name);o({name:W(p.name),value:d,value_type:"string",variable_description:`variable for ${d}`})}}}return{test_id:this.testId,version:"v4",auto_heal_version:this.config.apMode==="v2"?"AH2":"",session_id:this.config.sessionId,org_id:String(this.config.orgId),user_id:String(this.config.userId),url:this.config.firstUrl??"",start_timestamp:this.config.startedAt,end_timestamp:this.config.endedAt,status:i,commit_id:this.config.commitId,instructions:t,modules:[],uploaded_files:l,test_params:[],test_level_variables:JSON.stringify(e),test_global_variables:r,max_network_wait:0,wait_buffer:0,network_throttle:{},secrets:this.config.secrets??[],totp:[],environment_id:0,environment:"",mobile_browser:!1,native_popups:[],smartui:{},module_index:0}}};export{Gt as a,Kt as b,_t as c};
@@ -1,4 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as o,b as i}from"./chunk-AIVOYTYQ.js";import{resolve as n}from"path";async function w(c,s,r={}){let e=i({verb:c,mode:"cli",contextRoot:n(process.cwd(),".context"),env:o(),write:r.write});try{let t=await s(e);return r.write&&t===0&&await e.lateBindContext(n(process.cwd(),".context")),t===1&&process.stderr.write(e.supportFooter()+`
3
- `),await e.end({exit_code:t}),t}catch(t){throw e.error("cli_crash"),process.stderr.write(e.supportFooter()+`
4
- `),await e.end({exit_code:1}),t}}export{w as a};
@@ -1,6 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{e as U}from"./chunk-EHN5HTUD.js";import{b as J,c as w,e as q,i as z,j as Q,k as X,l as Y,m as T}from"./chunk-4WOVHRI2.js";import{a as G}from"./chunk-OTMAFCZK.js";import{copyFileSync as le,cpSync as pe,existsSync as $,mkdirSync as ue,readFileSync as Oe,readdirSync as ce,rmSync as Te,writeFileSync as Ae}from"fs";import{dirname as _e,isAbsolute as Ee,join as y,relative as Le,resolve as Ke}from"path";import{writeFileSync as ge,mkdirSync as Se,readFileSync as ye}from"fs";import{dirname as Re,basename as Z}from"path";function te(e){let t=e.outPath??w(e.sourcePath);Se(Re(t),{recursive:!0});let s=[];s.push("---"),s.push(`test: ../${Z(e.sourcePath)}`),s.push(`status: ${e.overallStatus}`),s.push(`started: ${e.startedISO}`),s.push(`duration_s: ${e.durationS}`),s.push(`session_id: ${e.sessionId}`),s.push("---",""),s.push(`# ${e.title??Z(e.sourcePath)} \u2014 Result`,"");for(let l=0;l<e.rootSteps.length;l++){let d=e.rootSteps[l],r=e.outcomes.find(u=>u.rootStepIndex===l+1);if(s.push(xe(d,r)),r?.stepMd5&&s.push(`md5: ${r.stepMd5}`),r?.status==="failed"&&r.reason&&s.push(`Reason: ${r.reason}`),r?.softFailures?.length)for(let u of r.softFailures){let o=u.reason?`: ${u.reason}`:"";s.push(`\u26A0 optional sub-step ${u.subStepIndex} failed${o}`)}d.body.kind==="objective"&&r?.status!=="skipped"&&s.push(d.body.text),s.push("")}return ge(t,s.join(`
3
- `),"utf8"),t}function xe(e,t){if(!t)return`## ${e.heading} (no outcome)`;let s=t.duration_s!=null?`${t.duration_s}s`:"\u2014";if(t.status==="skipped")return`## ${e.heading} \u23ED skipped`;let l=t.softFailed?" (optional)":"";if(t.refKind&&t.status==="passed"){let d=t.helperResultRelPath?` \u2192 ${t.helperResultRelPath}`:"";return`## ${e.heading} \u2713 passed (via @${t.refKind} ${t.refLabel} \u2014 ${t.inlinedCount} inlined steps, ${s}${d})`}if(t.refKind&&t.status==="failed"){let d=t.failedSubStepIndex&&t.failedSubStepIndex.length>0?` \u2014 at sub-step ${t.failedSubStepIndex.join(" \u2192 sub-step ")}`:"",r=t.helperResultRelPath?` \u2192 ${t.helperResultRelPath}`:"";return`## ${e.heading} \u2717 failed${l} (via @${t.refKind} ${t.refLabel}${d}, ${s}${r})`}return t.status==="passed"?`## ${e.heading} \u2713 passed (${s})`:`## ${e.heading} \u2717 failed${l} (${s})`}var Ie=/^##\s+(.+?)\s+(✓ passed|✗ failed(?:\s+\(optional\))?|⏭ skipped)(?:\s+\((.*)\))?\s*$/,ke=/via\s+@\w+\s+(\S+).*?(?:→\s+(\S+))?\s*$/,be=/^md5:\s+([a-f0-9]{32})\s*$/;function ee(e,t){for(let s=t;s<e.length&&!/^##\s/.test(e[s]);s++){if(e[s].trim()==="")continue;let l=be.exec(e[s]);return l?l[1]:null}return null}function D(e){let s=ye(e,"utf8").split(`
4
- `),l="passed";if(s[0]?.trim()==="---")for(let r=1;r<s.length&&s[r].trim()!=="---";r++){let u=/^status:\s+(passed|failed|interrupted)\s*$/.exec(s[r]);u&&(l=u[1])}let d=[];for(let r=0;r<s.length;r++){let u=Ie.exec(s[r]);if(!u)continue;let o=u[1],n=u[2],c=u[3]??"",m=n.startsWith("\u2713")?"passed":n.startsWith("\u23ED")?"skipped":"failed";if(/via\s+@/.test(c)){let f=ke.exec(c),v=f?.[1]??"",x=f?.[2]??null;d.push({kind:"import",heading:o,status:m,md5:ee(s,r+1),importPath:v,helperResultRelPath:x})}else d.push({kind:"objective",heading:o,status:m,md5:ee(s,r+1)})}return{overallStatus:l,steps:d}}import{copyFileSync as se,existsSync as C,mkdirSync as ve,writeFileSync as ne,promises as Ue}from"fs";import{join as M,dirname as re,basename as Pe}from"path";async function ie(e){for(let t=0;t<e.totalRunDirs;t++){let s=e.runIndex+t,l=M(e.sessionDir,"runs",String(s)),d=M(e.stagingStepDir,"flows",String(t));ve(d,{recursive:!0});let r=M(d,"actions.ndjson");if(e.packTestDir){let n=M(e.packTestDir,"logs",`${s}-actions.ndjson`);if(C(n)){se(n,r);continue}let c=re(re(e.packTestDir)),m=Pe(e.packTestDir),R=C(c)?await U(c,`tests/${m}/logs/${s}-actions.ndjson`).catch(()=>null):null;ne(r,R??"");continue}let u=[M(l,"run-test","actions.ndjson"),M(l,"actions.ndjson")],o=!1;for(let n of u)if(C(n)){se(n,r),o=!0;break}o||ne(r,"")}}import{existsSync as A,readdirSync as we}from"fs";import{dirname as $e,join as j,basename as H}from"path";function et(e,t){let s=[];return e.steps.forEach((l,d)=>{let r=t[d];!l.replayOnly||!r||r.kind!=="author"||s.push({flatIndex:l.flatIndex,file:l.owningFile,heading:l.trace[l.trace.length-1].heading,kind:l.replayOnly,reason:r.reason})}),s}function tt(e){let t=[],s=new Set,l=new Map;function d(n){if(l.has(n))return l.get(n);let c=w(n),m=A(c)?D(c):null;return l.set(n,m),m}let r=new Map;function u(n){if(r.has(n))return r.get(n);let c=j(n,"Result.md"),m=A(c)?D(c):null;return r.set(n,m),m}function o(n){for(let c=1;c<n.trace.length;c++){let m=n.trace[c-1],R=d(m.file);if(!R)continue;let f=R.steps[m.stepIndex-1];if(f){if(f.kind!=="import")return{kind:"author",reason:"structure-mismatch"};if(H(f.importPath)!==H(n.trace[c].file))return{kind:"author",reason:"structure-mismatch"};if(f.md5!=null&&f.md5!==m.rowMd5)return{kind:"author",reason:"structure-mismatch"}}}return null}for(let n of e.steps){let c=n.trace[n.trace.length-1].stepIndex,m=n.replayOnly,R=s.has(n.owningFile);for(let g=0;g<n.trace.length-1&&!R;g++)s.has(n.trace[g].file)&&(R=!0);if(R&&!m){t.push({kind:"author",reason:d(n.owningFile)===null?"no-result-md":"downstream-of-divergence"});continue}let f=o(n);if(f){for(let g=0;g<n.trace.length;g++)s.add(n.trace[g].file);if(!m){t.push(f);continue}}let v=d(n.owningFile),x;if(v===null&&n.trace.length>1){let g=W(n.trace);x=oe(n,u(g),c,g)}else x=oe(n,v,c);if(m&&x.kind==="replay"&&(x={...x,replayOnly:m}),t.push(x),x.kind==="author"){s.add(n.owningFile);for(let g=0;g<n.trace.length-1;g++)s.add(n.trace[g].file)}}return t}function oe(e,t,s,l=null){if(!t)return{kind:"author",reason:"no-result-md"};let d=t.steps[s-1];if(!d)return{kind:"author",reason:"no-result-md"};if(d.kind!=="objective")return{kind:"author",reason:"structure-mismatch"};if(d.status!=="passed")return{kind:"author",reason:"recorded-failed"};let r=T(e);if(r!==d.md5)return{kind:"author",reason:"md5-mismatch"};let u=l===null?X(e.owningFile,s,r.slice(0,8)):j(l,".internal","steps",`${s}-${r.slice(0,8)}`),o=De(u);return o===0?{kind:"author",reason:"missing-recording"}:{kind:"replay",recordingDir:u,flowCount:o}}function De(e){let t=j(e,"flows");if(!A(t))return 0;let s;try{s=we(t,{withFileTypes:!0}).filter(d=>d.isDirectory()&&/^\d+$/.test(d.name)).map(d=>parseInt(d.name,10))}catch{return 0}if(s.length===0)return 0;let l=Math.max(...s);for(let d=0;d<=l;d++)if(!A(j(t,String(d),"actions.ndjson")))return 0;return l+1}function st(e){return e.some(t=>t.kind==="author")}function nt(e){for(let t=0;t<e.length;t++)if(e[t].kind==="author")return t;return e.length}function W(e){let t=r=>{let u=H(r);return u.endsWith("_test.md")?u.slice(0,-8):u.endsWith(".md")?u.slice(0,-3):u},s=t(e[0].file),l=t(e[e.length-1].file),d=e.slice(0,-1).map(r=>String(r.stepIndex));return j($e(e[e.length-1].file),`helper-output-${l}-${s}-${d.join("-")}`)}function rt(e){return Array.from({length:e.flowCount},(t,s)=>j(e.recordingDir,"flows",String(s),"actions.ndjson"))}import{existsSync as ae,mkdirSync as Me,rmSync as je,cpSync as Fe}from"fs";function de(e,t){ae(e)&&(ae(t)&&je(t,{recursive:!0,force:!0}),Me(t,{recursive:!0}),Fe(e,t,{recursive:!0}))}async function St(e){let t=new Map;for(let o of e.stepRunRecords)t.set(o.testmdStepIndex,o);let s=e.authoredFlatIdx??new Set,l=[],d=[],r=new Map,u=o=>{if(r.has(o))return r.get(o);let n=y(o,"Result.md"),c=$(n)?D(n):null;return r.set(o,c),c};for(let o of e.resolvedTest.unitFiles){let n=o.file===e.resolvedTest.rootPath,c=G(o.file,Oe(o.file,"utf8")),m=w(o.file),R=$(m)?D(m):null,f=[],v=[],x=[],g=[];if(!n)for(let a of e.resolvedTest.steps){if(a.owningFile!==o.file||a.trace.length<2)continue;let i=W(a.trace);g.includes(i)||g.push(i)}let F=a=>{if(R!==null)return null;for(let i of g){let P=u(i)?.steps[a-1];if(P)return{row:P,dir:i}}return null},V=[],_=!1,B=!1,E=!1,L=!1;for(let a of c.steps){let i=a.index,p=R?.steps[i-1];if(a.body.kind==="objective"){let h=e.resolvedTest.steps.filter(S=>S.owningFile===o.file&&S.trace[S.trace.length-1].stepIndex===i&&t.has(S.flatIndex)),I=h.length>0?h[h.length-1]:null;if(I){_=!0,s.has(I.flatIndex)&&(B=!0);let S=T(I),k;n?k=e.outcomes.find(he=>he.rootStepIndex===i)??{rootStepIndex:i,status:"skipped"}:k={rootStepIndex:i,status:fe(I,e.outcomes)},k.status==="failed"&&(E=!0),k.stepMd5==null&&(k.stepMd5=S),f.push(k),v.push({stepIndex:i,md5:S,rec:t.get(I.flatIndex)}),(!p||p.kind!=="objective"||p.status!==k.status||k.status==="passed"&&p.md5!==S)&&(L=!0)}else if(p&&p.kind==="objective")f.push({rootStepIndex:i,status:p.status,...p.md5?{stepMd5:p.md5}:{}}),x.push(i);else if(!n&&F(i)?.row.kind==="objective"){let S=F(i),k=S.row;f.push({rootStepIndex:i,status:k.status,...k.md5?{stepMd5:k.md5}:{}}),V.push({psIdx:i,dir:S.dir})}else n?f.push(e.outcomes.find(S=>S.rootStepIndex===i)??{rootStepIndex:i,status:"skipped"}):f.push({rootStepIndex:i,status:"skipped"});continue}let P=Ee(a.body.path)?a.body.path:Ke(_e(o.file),a.body.path),O=Y({path:a.body.path,bindings:a.body.bindings,optional:a.optional??!1}),K=Le(J(o.file),w(P)),N=e.resolvedTest.steps.filter(h=>h.trace.some((I,S)=>S<h.trace.length-1&&I.file===o.file&&I.stepIndex===i)&&t.has(h.flatIndex));if(N.length>0){_=!0;let h;if(n)h=e.outcomes.find(I=>I.rootStepIndex===i)??{rootStepIndex:i,status:"passed",refKind:"import",refLabel:a.body.path};else{let I=N.some(S=>fe(S,e.outcomes)==="failed");h={rootStepIndex:i,status:I?"failed":"passed",refKind:"import",refLabel:a.body.path,inlinedCount:N.length}}h.status==="failed"&&(E=!0),h.stepMd5==null&&(h.stepMd5=O),h.helperResultRelPath==null&&(h.helperResultRelPath=K),f.push(h),(!p||p.kind!=="import"||p.status!==h.status||p.md5!==O)&&(L=!0)}else if(p&&p.kind==="import")f.push({rootStepIndex:i,status:p.status,refKind:"import",refLabel:p.importPath,...p.md5?{stepMd5:p.md5}:{},...p.helperResultRelPath?{helperResultRelPath:p.helperResultRelPath}:{}});else if(!n&&F(i)?.row.kind==="import"){let h=F(i).row;f.push({rootStepIndex:i,status:h.status,refKind:"import",refLabel:a.body.path})}else n?f.push(e.outcomes.find(h=>h.rootStepIndex===i)??{rootStepIndex:i,status:"skipped",refKind:"import",refLabel:a.body.path}):f.push({rootStepIndex:i,status:"skipped",refKind:"import",refLabel:a.body.path})}if(!(n||_&&(B||E||R===null||L)))continue;l.push(o.file);let b=z(o.file);ue(y(b,".internal"),{recursive:!0});for(let a of v){let i=y(b,".internal","steps",`${a.stepIndex}-${a.md5.slice(0,8)}`);ue(i,{recursive:!0}),await ie({sessionDir:e.sessionDir,runIndex:a.rec.runIndex,totalRunDirs:a.rec.totalRunDirs,stagingStepDir:i,packTestDir:e.packTestDir})}if(x.length>0){let a=Q(o.file);if($(a))for(let i of ce(a)){let p=parseInt(i.split("-")[0]??"",10);!Number.isNaN(p)&&x.includes(p)&&pe(y(a,i),y(b,".internal","steps",i),{recursive:!0})}}for(let a of V){let i=y(a.dir,".internal","steps");if($(i))for(let p of ce(i))parseInt(p.split("-")[0]??"",10)===a.psIdx&&pe(y(i,p),y(b,".internal","steps",p),{recursive:!0})}let me=f.some(a=>a.status==="failed");if(te({sourcePath:o.file,title:c.title,rootSteps:c.steps,outcomes:f,overallStatus:n?e.overallStatus:me?"failed":"passed",startedISO:e.startedISO,durationS:n?e.durationS:0,sessionId:e.sessionId,outPath:y(b,"Result.md")}),n){let a={};e.commitId&&(a.commit_id=e.commitId),e.tmsIds.testId&&(a.test_id=e.tmsIds.testId),e.tmsIds.testcaseId&&(a.testcase_id=e.tmsIds.testcaseId),e.tmsIds.projectId&&(a.project_id=e.tmsIds.projectId),e.tmsIds.folderId&&(a.folder_id=e.tmsIds.folderId),e.tmsIds.orgId&&(a.org_id=e.tmsIds.orgId),e.tmsIds.sessionName&&(a.session_name=e.tmsIds.sessionName),Ae(y(b,".internal","meta.json"),JSON.stringify(a,null,2)+`
5
- `,"utf8");let i=y(e.sessionDir,"execution.json");if($(i))try{le(i,y(b,".internal","execution.json"))}catch{}if(e.codeExportDir){let p=e.codeExportLanguage??"python",P=e.codeExportFramework??"playwright",O=y(b,`${P}-${p}-code`);try{de(e.codeExportDir,O)}catch(K){process.stderr.write(`warn: codegen copy failed: ${K.message}
6
- `)}}}else if(o.kind==="test"||o.kind==="module"){let a=q(o.file);if($(a))try{le(a,y(b,".internal","meta.json"))}catch{}}!n&&g.length>0&&f.every(i=>i.status!=="skipped")&&d.push({unitFile:o.file,dirs:g.filter(i=>$(i))})}return{changedUnitFiles:l,legacySweep:d}}function yt(e){for(let t of e)try{Te(t,{recursive:!0,force:!0})}catch{}}function fe(e,t){let s=e.trace[0].stepIndex,l=t.find(o=>o.rootStepIndex===s);if(!l)return"skipped";if(l.status==="passed")return"passed";if(l.status==="skipped")return"skipped";let d=e.trace.slice(1).map(o=>o.stepIndex),r=l.failedSubStepIndex??[],u=Math.min(d.length,r.length);for(let o=0;o<u;o++)if(d[o]!==r[o])return d[o]<r[o]?"passed":"skipped";return d.length===r.length?"failed":d.length<r.length?"passed":"skipped"}export{te as a,et as b,tt as c,st as d,nt as e,rt as f,de as g,St as h,yt as i};
@@ -1,2 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as j}from"./chunk-O5U6EAL3.js";import{d as K}from"./chunk-RKXHVP2Z.js";import{a as L}from"./chunk-5Y2G4NC7.js";import{a as M}from"./chunk-YCCUBQY4.js";import{y as s}from"./chunk-33GXXC2L.js";import{a as O}from"./chunk-HCBYKLMW.js";import{a as x,b as n,i as D,k as E}from"./chunk-C44QQJR4.js";import{a as I}from"./chunk-6YGTRKDT.js";import{e as y}from"./chunk-UR6MHSHU.js";var g=y(O(),1);function ee(e){let t=e.findIndex(r=>r.free);return t>=0?t:null}var q=60,Q=100;function te({headline:e,ask:t=!1,rows:r,sel:o,focused:d,freeText:c=null,freeTextNote:h,sublines:b=[]}){let{stdout:p}=E(),i=p?.columns??80,v=i<q,k=Math.min(i-1,Q),u=a=>d&&o===a?(0,g.jsx)(n,{color:s.assuranceAccent,children:"\u276F"}):" ",m=t?`? ${e}`:e,A=Math.max(4,k-3),S=b.map((a,w)=>(0,g.jsx)(n,{color:s.dim,children:` ${a.length>A?`${a.slice(0,A-1)}\u2026`:a}`},`sub-${w}`)),R=0,B=r.map((a,w)=>a.free?c?(0,g.jsxs)(x,{flexDirection:"column",children:[(0,g.jsxs)(x,{children:[(0,g.jsxs)(n,{children:[(0,g.jsx)(n,{color:s.assuranceAccent,children:"\u276F"})," ",(0,g.jsx)(n,{color:s.dim,children:"\u270E "})]}),(0,g.jsx)(M,{value:c.value,onChange:c.onChange,onSubmit:c.onSubmit,onCancel:c.onCancel,placeholder:a.label})]}),h?(0,g.jsx)(n,{color:s.muted,children:` ${h}`}):null]},a.key):(0,g.jsxs)(n,{children:[u(w)," ",(0,g.jsx)(n,{color:s.dim,children:`\u270E ${a.label}`})]},a.key):(R+=1,(0,g.jsxs)(n,{bold:d&&o===w,children:[u(w),` ${R}. ${a.label}`,a.detail?(0,g.jsx)(n,{color:s.dim,bold:!1,children:` \u2014 ${a.detail}`}):null]},a.key)));return v?(0,g.jsxs)(x,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,g.jsx)(n,{bold:!0,color:s.assuranceAccent,children:m}),S,B]}):(0,g.jsxs)(x,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,g.jsx)(n,{bold:!0,color:s.assuranceAccent,children:m}),S,(0,g.jsx)(n,{children:" "}),B]})}var H=y(I(),1);var $=y(O(),1),N=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function le(e){let t=e.replace(/…$/,"");return t&&t.charAt(0).toLowerCase()+t.slice(1)}function F(e,t){if(e.length<=t)return e;if(t<=1)return"\u2026";let r=Math.ceil((t-1)/2),o=Math.floor((t-1)/2);return`${e.slice(0,r)}\u2026${o>0?e.slice(-o):""}`}function ce({status:e,meta:t,tallies:r,keys:o,child:d,cols:c}){let{stdout:h}=E(),b=c??h?.columns??80,p=e.kind==="working"||e.kind==="child-working",[i,v]=(0,H.useState)(0);L(()=>v(f=>f+1),p?120:null);let k=N[i%N.length],u,m;switch(e.kind){case"working":u=`${k} ${e.step}${e.elapsedS!==void 0?` \xB7 ${e.elapsedS}s`:""}`,m=s.assuranceAccent;break;case"waiting":u=`\u25CF waiting on you${e.pending?` \u2014 ${e.pending} question${e.pending===1?"":"s"}`:""}`,m=s.amber;break;case"idle":u="\u25CF idle",m=s.assuranceAccent;break;case"card":u=`\u25CF card ${e.n} of ${e.m}`,m=s.amber;break;case"child-working":u=`${k} child: ${e.step}`,m=s.assuranceAccent;break;case"child-waiting":u="\u25CF child waiting on you",m=s.amber;break}let A=d?`${t.verb} \u25B8 ${d.verb}`:t.verb,S=d?.sid?t.sid?`${F(t.sid,14)} \u25B8 ${d.sid}`:d.sid:t.sid,R=t.env==="prod"?"":t.env,B=[A,S,R].filter(Boolean),a=" \xB7 ",w=u.length+a.length+B.join(a).length,C=t.subject;if(C){let f=b-w-a.length;C=f>=8?F(C,f):void 0}let _=[A,...C?[C]:[],S,R].filter(Boolean).join(a);return(0,$.jsxs)(x,{flexDirection:"column",children:[(0,$.jsx)(n,{color:s.muted,children:"\u2500".repeat(Math.max(1,b))}),(0,$.jsxs)(n,{children:[(0,$.jsx)(n,{color:m,children:u}),(0,$.jsx)(n,{color:s.dim,children:`${a}${_}`})]}),(0,$.jsx)(n,{color:s.dim,children:r.items.length>0?r.items.join(a):" "}),(0,$.jsx)(n,{color:s.muted,children:o.join(a)})]})}var P=y(I(),1);function ue({onToggleThinking:e,onCtrlC:t,explorer:r,panel:o}){let c=(0,P.useRef)(null),h=(0,P.useRef)(""),b=()=>{c.current&&clearTimeout(c.current),c.current=null,h.current=""};return(0,P.useEffect)(()=>b,[]),D((p,i)=>{if(i.ctrl&&p==="t"){e();return}if(i.ctrl&&p==="c"){t();return}if(!i.ctrl&&p.includes("")){t();return}if(!i.ctrl&&p.includes("")){e();return}if(r&&r.isOpen()){let v=()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{b(),r.onBack()},150)};if(c.current){if(i.upArrow||i.downArrow||i.return){b(),i.return?r.onEnter():r.onMove(i.upArrow?-1:1);return}if(h.current+=p,h.current==="["){v();return}let k=h.current;b();let u=/^\[([ABCD])/.exec(k);if(u){(u[1]==="A"||u[1]==="B")&&r.onMove(u[1]==="A"?-1:1);return}r.onBack();return}if(i.upArrow){r.onMove(-1);return}if(i.downArrow){r.onMove(1);return}if(i.return){r.onEnter();return}if(i.escape){h.current="",v();return}return}if(o&&o.isFocused()){let v=()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{b(),o.onBack()},150)};if(c.current){if(i.upArrow||i.downArrow||i.return||i.leftArrow||i.rightArrow){b(),i.return?o.onSelect():i.leftArrow?o.onLeft?.():i.rightArrow?o.onRight?.():o.onMove(i.upArrow?-1:1);return}if(h.current+=p,h.current==="["){v();return}let k=h.current;b();let u=/^\[([ABCD])/.exec(k);if(u){u[1]==="A"||u[1]==="B"?o.onMove(u[1]==="A"?-1:1):u[1]==="C"?o.onRight?.():o.onLeft?.();return}o.onBack();return}if(i.upArrow){o.onMove(-1);return}if(i.downArrow){o.onMove(1);return}if(i.leftArrow){o.onLeft?.();return}if(i.rightArrow){o.onRight?.();return}if(i.return){o.onSelect();return}if(i.escape){h.current="",v();return}if(/^[1-9]$/.test(p)){o.onDigit(Number(p));return}if(i.tab){o.onTab?.();return}if(p===" "&&o.isMulti()){o.onSpace();return}if(p&&!i.ctrl&&!i.meta){o.onType(p);return}return}}),null}var l=y(O(),1);function X(e){return e.kind==="REVIEW"?[{v:"approve",label:"approve",detail:"mark it reviewed and trusted"},{v:"archive",label:"archive",detail:"reject it \u2014 asks for a reason; impact shown above"},{v:"defer",label:"defer",detail:"not now \u2014 stays queued"}]:e.kind==="PAIR"?[{v:"merge",label:"merge",detail:"duplicate \u2014 fold into the older item (it stays unreviewed)"},{v:"keep_both",label:"keep both",detail:"genuinely distinct \u2014 promote both"},{v:"defer",label:"defer",detail:"not now \u2014 stays queued"}]:e.kind==="ARCHIVE"?[{v:"archive",label:"retire",detail:"hidden from now on; history is kept and it can be reverted"},{v:"skip",label:"skip",detail:"keep it \u2014 decided, never re-offered"},{v:"defer",label:"defer",detail:"not now \u2014 the plan re-offers it"}]:e.heldPayload?[{v:"approve",label:"approve update",detail:"commit the held payload \u2014 impact preview above"},{v:"skip",label:"keep current",detail:"drop the held payload (the owner's disk state stays untouched)"},{v:"defer",label:"defer",detail:"not now \u2014 stays held"}]:[{v:"approve",label:"approve",detail:e.kind==="ADD"?"commit + design it":"commit the updated version (old\u2192new redirect)"},{v:"skip",label:e.origin==="content-change"?"reject":"skip",detail:e.origin==="content-change"?"drop the staged proposal \u2014 nothing committed":"leave it as is"},{v:"defer",label:"defer",detail:"not now \u2014 the plan keeps it staged"}]}function V(e){let t=X(e);return e.viewDiff&&t.push({v:"view_diff",label:"view diff",detail:"full old \u2192 new"}),t}function W(e){return e.kind==="ARCHIVE"?null:V(e).length}var Y={ADD:{color:s.green??"green"},MODIFY:{color:"yellow"},ARCHIVE:{color:s.red},REVIEW:{color:"cyan"},PAIR:{color:"magenta"}},U=60;function be({card:e,position:t,sel:r=0,focused:o=!1,freeText:d=null,editorIntent:c="steer"}){let{stdout:h}=E(),b=h?.columns??80,p=b<U,i=V(e),v=W(e),k=Y[e.kind],u=f=>o&&r===f?(0,l.jsx)(n,{color:s.assuranceAccent,children:"\u276F"}):" ",m=e.impact,A=m&&"stale_refs"in m&&m.stale_refs.length>0?`${e.kind==="ARCHIVE"?"retiring leaves":"approving marks"} ${m.stale_refs.length} item(s) stale`+((m.direct_refs?.length??0)>0?` \u2014 ${m.direct_refs.length} directly touched: ${m.direct_refs.join(", ")}`:""):m&&"design_children"in m?`${e.kind==="REVIEW"?"archiving drops":"merging folds"} ${m.design_children} design child(ren)`:null,S=e.provenance&&e.provenance!==e.why?e.provenance:e.origin??null,R=[{label:"why",text:e.why},...S?[{label:"from",text:S,dimmer:!0}]:[],...e.tier?[{label:"match",text:e.tier,dimmer:!0}]:[],...A?[{label:"impact",text:A}]:[]],B=Math.max(...R.map(f=>f.label.length)),a="? reconcile",w=`item ${t.n} of ${t.of}`,C=(0,l.jsxs)(x,{flexDirection:"column",children:[(0,l.jsx)(x,{paddingLeft:2,children:(0,l.jsxs)(n,{bold:!0,children:[(0,l.jsx)(n,{color:k.color,children:`[${e.kind}]`}),` ${j(e.title)}`]})}),R.map((f,T)=>(0,l.jsx)(x,{paddingLeft:2,children:(0,l.jsxs)(n,{children:[(0,l.jsx)(n,{color:s.dim,children:`${f.label.padEnd(B)} `}),(0,l.jsx)(n,{color:f.dimmer?s.dim:void 0,children:f.text})]})},`f-${T}`)),e.diffSummary?(0,l.jsx)(x,{paddingLeft:2,children:(0,l.jsx)(n,{color:s.dim,children:e.diffSummary})}):(e.diff??[]).map((f,T)=>(0,l.jsx)(x,{paddingLeft:4,children:(0,l.jsx)(n,{color:f.op==="-"?"red":"green",children:`${f.op==="-"?"\u2212":"+"} ${f.field==="criteria"?"criterion":f.field}: ${f.text}`})},`d-${T}`)),(e.citeLines??[]).map((f,T)=>(0,l.jsx)(x,{paddingLeft:2,children:(0,l.jsx)(n,{color:s.dim,children:f})},`c-${T}`)),(0,l.jsx)(n,{children:" "}),i.map((f,T)=>(0,l.jsxs)(n,{children:[u(T),` ${T+1}. ${f.label}`,(0,l.jsx)(n,{color:s.dim,children:` \u2014 ${f.detail}`})]},`o-${T}`)),v!==null||d&&c==="because"?d?(0,l.jsxs)(x,{flexDirection:"column",children:[(0,l.jsxs)(x,{children:[(0,l.jsxs)(n,{children:[(0,l.jsx)(n,{color:s.assuranceAccent,children:"\u276F"})," ",(0,l.jsx)(n,{color:s.dim,children:"\u270E "})]}),(0,l.jsx)(M,{value:d.value,onChange:d.onChange,onSubmit:d.onSubmit,onCancel:d.onCancel,placeholder:c==="because"?"why archive it?":"say what to adjust"})]}),(0,l.jsx)(n,{color:s.muted,children:c==="because"?" submits as: archive \xB7 your reason goes on the record":e.kind==="PAIR"?" submits as: defer \xB7 your note parks with the card (it re-offers)":" submits as: approve \xB7 your words steer the re-design"})]}):v!==null?(0,l.jsxs)(n,{children:[u(v)," ",(0,l.jsx)(n,{color:s.dim,children:e.kind==="PAIR"?"\u270E defer with a note \u2014 say what you noticed":"\u270E approve with changes \u2014 say what to adjust"})]}):null:null]});if(p)return(0,l.jsxs)(x,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,l.jsx)(n,{bold:!0,color:s.assuranceAccent,children:a}),(0,l.jsx)(n,{color:s.dim,children:w}),C]});let _=Math.max(2,Math.min(b-1,100)-a.length-w.length);return(0,l.jsxs)(x,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,l.jsxs)(n,{children:[(0,l.jsx)(n,{bold:!0,color:s.assuranceAccent,children:a})," ".repeat(_),(0,l.jsx)(n,{color:s.dim,children:w})]}),(0,l.jsx)(n,{children:" "}),C]})}var z={"acceptance criteria":1,scenarios:2,"acceptance criteria + exercises":3,"tests + gaps":4};function we(e,t){let r=[],o=K(e.turns).entries.length;if(t==="design"){let c;for(let b=e.ledger.length-1;b>=0;b--){let p=e.ledger[b];if(p.kind==="banner"&&p.text.startsWith("designing: ")){c=p.text.slice(11);break}}let h=c?z[c]:void 0;h&&r.push(`phase ${h}/4`),o>0&&r.push(`${o} item${o===1?"":"s"} this session`)}else o>0&&r.push(`${o} saved as draft${o===1?"":"s"}`);let d=e.pending?e.pending.resolution.filter(c=>!c).length:0;return d>0&&r.push(`${d} question${d===1?"":"s"} pending`),e.credits&&r.push(`${e.credits.total.toFixed(1)} credits`),{items:r}}function ke(e,t){let r=[],o=e.applied+e.committed+e.retired;r.push(`${o} applied`),r.push(`${t} to decide`);let d=[];return e.skipped>0&&d.push(`${e.skipped} skipped`),e.deferred>0&&d.push(`${e.deferred} deferred`),e.failed>0&&d.push(`${e.failed} failed`),{items:[...r,...d]}}function Ae(e,t){let r=["\u2191\u2193 select","\u23CE confirm"];return e.multi_select&&r.push("space toggle"),t.batchCount>1&&r.push("\u2190 \u2192 questions"),(e.allow_free_text||e.options.some(o=>o.input===!0))&&r.push("\u270E type your own"),t.canAttach&&r.push("@ attach a file or URL"),t.escBack&&r.push("esc back"),{keys:r}}function Se(e,t){let r=["\u2191\u2193 select","\u23CE confirm"];return e.some(o=>o.free)&&r.push("\u270E type your own"),t.escBack&&r.push("esc back"),{keys:r}}function Re(e){let t=["\u2191\u2193 select","\u23CE confirm","1-9 verdict"];return W(e)!==null&&t.push("type = adjust"),t.push("esc \xB7 nothing to undo"),{keys:t}}export{ee as a,te as b,le as c,ce as d,ue as e,X as f,V as g,W as h,be as i,we as j,ke as k,Ae as l,Se as m,Re as n};
@@ -1,5 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as N}from"./chunk-UD7KKHPW.js";import{closeSync as D,existsSync as W,mkdirSync as C,openSync as J,readFileSync as M,readdirSync as j,renameSync as $,rmSync as g,watch as U,writeFileSync as _}from"fs";import{join as h}from"path";import{randomBytes as X}from"crypto";var F=1440*60*1e3,L=class extends Error{constructor(l,u,f,k){super(`${l}: ${f}`);this.code=l;this.key=u;this.holder=k}},E=e=>(e?.now??(()=>new Date))();function P(e){if(!Number.isInteger(e)||e<=0)return!1;try{return process.kill(e,0),!0}catch(s){return s.code==="EPERM"}}function G(e,s){let l=s.getTime()-new Date(e.ts).getTime();return!P(e.pid)||l>=F||Number.isNaN(l)}var m=e=>h(e,"locks"),H=e=>h(m(e),"waiters");function T(e,s){return s.kind==="context"?h(m(e),"context.lock"):s.kind==="extract"?h(m(e),"extract.lock"):h(m(e),`uc-${s.id}.lock`)}var x=e=>e.kind==="uc"?e.id:e.kind,v=e=>e.kind==="uc"?`uc:${e.id}`:e.kind,K=e=>e.kind==="uc"?e.id:`~${e.kind}`;function I(e){return[...e].sort((s,l)=>K(s)<K(l)?-1:K(s)>K(l)?1:0)}function p(e){try{return JSON.parse(M(e,"utf8"))}catch{return null}}function q(e,s,l){let u=`${e}.break-${l}`;try{$(e,u)}catch(k){if(k.code==="ENOENT")return!1;throw k}let f;try{f=JSON.parse(M(u,"utf8"))}catch{f=null}if(f===null||f.nonce===s)return g(u,{force:!0}),!0;try{$(u,e)}catch{g(u,{force:!0})}return!1}var y=new Map,O=new Map;function V(e,s,l){let u=o=>`${e}|${s}|${x(o)}`;function f(o,d,c=0){if(c>20)throw new L("LOCK_CONTENTION_UNSETTLED",o,`${v(o)}: lock contention did not settle`);let i=T(e,o);C(m(e),{recursive:!0});let n=X(8).toString("hex");try{let t=J(i,"wx",384);return _(t,JSON.stringify({...d,nonce:n})+`
3
- `),D(t),n}catch(t){if(t.code!=="EEXIST")throw t;let r=p(i),a=E(l);if(r!==null&&!G(r,a)){let S=o.kind==="context"?"CONTEXT_HELD":o.kind==="extract"?"EXTRACT_HELD":"UC_HELD";throw new L(S,o,`${v(o)} is held by ${r.owner_sid} (${r.verb})`,{owner_sid:r.owner_sid,pid:r.pid,ts:r.ts,verb:r.verb,alive:P(r.pid)})}return q(i,r?.nonce,n)&&N({type:"lock_steal",key:v(o),stale_owner:r?.owner_sid??"corrupt",by:s,ts:a.toISOString()}),f(o,d,c+1)}}function k(o,d){let c=!1;return{keys:d,assertHeld(){for(let{key:i,sk:n}of o){let t=y.get(n),r=t?p(t.path):null;if(!t||r===null||r.nonce!==t.nonce)throw new L("LOCK_LOST",i,`${v(i)} grant was taken over or removed`)}},touch(){for(let{sk:i}of o){let n=y.get(i);if(!n)continue;let t=p(n.path);t!==null&&t.nonce===n.nonce&&_(n.path,JSON.stringify({...t,ts:E(l).toISOString()})+`
4
- `,{mode:384})}},release(){if(!c){c=!0;for(let{sk:i}of[...o].reverse()){let n=y.get(i);if(n&&(n.count-=1,n.count<=0)){y.delete(i);let t=p(n.path);t!==null&&t.nonce===n.nonce&&g(n.path,{force:!0})}}}}}}function w(o,d){let c=I(o),i=[];try{for(let n of c){let t=u(n),r=y.get(t);if(r)r.count+=1;else{let a=f(n,{owner_sid:s,pid:process.pid,ts:E(l).toISOString(),verb:d.verb??"unknown",hold:d.hold,...n.kind==="uc"?{logical_display:n.id.toUpperCase()}:{}});y.set(t,{nonce:a,count:1,path:T(e,n),key:n})}i.push({key:n,sk:t})}return k(i,c)}catch(n){for(let{sk:t}of[...i].reverse()){let r=y.get(t);if(r&&(r.count-=1,r.count<=0)){y.delete(t);let a=p(r.path);a!==null&&a.nonce===r.nonce&&g(r.path,{force:!0})}}throw n}}return{acquire:w,tryAcquire(o,d){try{return w(o,d)}catch(c){if(c instanceof L&&(c.code==="UC_HELD"||c.code==="CONTEXT_HELD"||c.code==="EXTRACT_HELD"))return{contended:c};throw c}},holder(o){return p(T(e,o))},async wait(o,d){let c=T(e,o);C(H(e),{recursive:!0});let i=h(H(e),`${x(o)}.${s}.${process.pid}.json`);try{_(i,JSON.stringify({sid:s,pid:process.pid,ts:E(l).toISOString()})+`
5
- `,{mode:384})}catch{}let n=Date.now()+d.timeoutMs,t=null,r=null;try{try{t=U(m(e),()=>{r?.()}),t.on("error",()=>{r?.(),t=null})}catch{t=null}for(;;){if(d.signal?.aborted)return"cancelled";let a=p(c);if(a===null||G(a,E(l)))return"free";let S=n-Date.now();if(S<=0)return"timeout";await new Promise(b=>{r=b;let A=setTimeout(b,Math.min(t?250:100,Math.max(1,S)));d.signal?.addEventListener?.("abort",()=>{clearTimeout(A),b()},{once:!0})}),r=null}}finally{t?.close(),g(i,{force:!0})}},async withKeySerialized(o,d){let i=I(o).map(a=>`${e}|${x(a)}`),n=i.map(a=>O.get(a)??Promise.resolve()),t,r=new Promise(a=>{t=a});for(let a of i)O.set(a,r);await Promise.all(n);try{return await d()}finally{t();for(let a of i)O.get(a)===r&&O.delete(a)}},releaseAll(o){let d=`${e}|${o}|`;for(let[c,i]of[...y]){if(!c.startsWith(d))continue;y.delete(c);let n=p(i.path);n!==null&&n.nonce===i.nonce&&g(i.path,{force:!0})}}}}function Y(e,s){let l=e.resolve(s);if(l===null)return{key:{kind:"uc",id:s.toLowerCase()},display:s};let u=e.displayNameOf(l.tip)??e.displayNameOf(l.cid);if(u!==null&&/^uc-\d+$/i.test(u))return{key:{kind:"uc",id:u.toLowerCase()},display:u.toUpperCase()};let f=new Map;for(let[d,c]of e.superseded)typeof c=="string"&&f.set(c,d);let k=l.cid,w=new Set;for(;f.has(k)&&!w.has(k);)w.add(k),k=f.get(k);let o=k.slice(0,12);return{key:{kind:"uc",id:o},display:u??o}}export{L as a,P as b,H as c,I as d,V as e,Y as f};
@@ -1,7 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{g as E}from"./chunk-R7QAS6LZ.js";import{i as S}from"./chunk-XS2LZFCH.js";import{a as C,b as k,c as R,d as D}from"./chunk-T7DGNWI2.js";import{j as T,k as $,l as b}from"./chunk-54JZ6VEW.js";import{c as y}from"./chunk-5DT7PIGB.js";import{a as O}from"./chunk-CH273NAE.js";import{C as _}from"./chunk-W3Z7AZNT.js";import{existsSync as H}from"fs";import{basename as q}from"path";import{appendFileSync as L,mkdirSync as U}from"fs";import{homedir as F}from"os";import{dirname as G,join as j}from"path";function P(c,s){let n=/^(DOCX_[A-Z_]+):/.exec(s)?.[1];if(n)try{let u=process.env.KANE_CONTEXT_REFUSAL_LOG??j(F(),".testmuai","kaneai","context-refusals.log");U(G(u),{recursive:!0}),L(u,`${new Date().toISOString()} ${n} ${c}
3
- `)}catch{}}async function w(c,s,n,u=process.cwd(),p){let l=O(u),g=[];if(s.as!==void 0&&c.length>1)return(n.err??n.out)(`error: --as names ONE source identity \u2014 pass a single file (got ${c.length})`,"AS_SINGLE_SOURCE"),{code:2,results:g};for(let o of c){if(R(o)){let a=D(o);if(a===null)return(n.err??n.out)(`error: ${o}: unsupported remote URL \u2014 supported: ${k.map(d=>d.hint).join("; ")}`,"UNSUPPORTED_URL"),{code:1,results:g};let r=await a.ingest(o,s.as,n,l,p);if(r.code!==0)return{code:r.code,results:g};r.result&&g.push({status:r.result.status==="versioned"?"versioned":r.result.status==="unchanged"?"unchanged":"created",source_id:r.result.source_id,source_cid:r.result.source_cid});continue}let f=s.as,v;if(f===void 0&&H(l)){let a=T(o),r=$(a);if(r){let d=_(l);d.heads.get(r)!=null&&d.heads.get(a)==null&&(v=r,n.isTTY&&await n.confirm(`${a} looks like a new version of existing source '${r}' \u2014 ingest as '${r}' (replaces the current version; items built on it go stale)?`)&&(f=r))}}let e;try{e=await b({contextDir:l,filePath:o,asId:f,confirmSameSource:n.isTTY?a=>n.confirm(`identical bytes already ingested as ${a} \u2014 treat as the same source?`):void 0,converters:{pdf:E,docx:S}})}catch(a){let r=a instanceof Error?a.message:String(a);return P(o,r),(n.err??n.out)(`error: ${o}: ${r}`,"INGEST_FAILED"),{code:1,results:g}}n.out(C(n.isTTY,e,q(o)));for(let a of e.warnings??[])n.out(`warning: ${a}`);if(e.composite&&(e.composite.delivered>0||e.composite.omitted>0)){let a=e.composite.pages!==void 0?` ${e.composite.pages} pages,`:"";n.out(`${e.source_id}: ${e.composite.kind},${a} ${e.composite.delivered} images delivered (${e.composite.omitted} omitted)`)}let m;if(!n.isTTY&&e.status==="created"){let a=_(l);for(let[r,d]of a.heads.entries())if(!(r===e.source_id||d==null)&&a.getNode(d)?.content.blob===e.blob){m=r,n.out(`hint: identical bytes already ingested as ${r} \u2014 merged later via review`);break}}g.push({status:e.status,source_id:e.source_id,source_cid:e.cid,...e.warnings?.length?{warnings:e.warnings}:{},...e.composite?{media:{kind:e.composite.kind,...e.composite.pages!==void 0?{pages:e.composite.pages}:{},delivered:e.composite.delivered,omitted:e.composite.omitted}}:{},...m?{duplicate_of:m}:{},...v&&f===void 0?{lineage_candidate:v}:{}})}return{code:0,results:g}}async function se(c,s,n,u=process.cwd(),p){return(await w(c,s,n,u,p)).code}async function ie(c,s){if(s.mode!=null&&!["interactive","agent","ci","override"].includes(s.mode)){let{makeHeadlessIO:t,agentRefusal:i}=await import("./headless-io-66RG5NN5.js");return i(t("ndjson","extract"),`ingest: --mode must be interactive | agent | ci | override, got '${s.mode}'`,"MODE_USAGE")}let n=y();if(s.mode==="interactive"&&!n)return process.stderr.write(`ingest: --mode interactive needs a TTY on stdin and stdout (use --mode agent|ci|override headless)
4
- `),2;let u=s.mode??(n?"interactive":void 0),p=u==="interactive"||u==="agent"||u==="override";if(!p&&(s.plan||s.force||s.trust!==void 0))return process.stderr.write(`ingest: --plan/--force/--trust steer the extraction \u2014 not available when only landing (use --mode agent to extract headless)
5
- `),2;let{createInterface:l}=await import("readline/promises"),g=u==="agent",o=g?(await import("./headless-io-66RG5NN5.js")).makeHeadlessIO("ndjson","extract"):null,f=[],v=()=>{for(let t of f.splice(0))o.event({type:"error",message:t.message,...t.code?{code:t.code}:{}})},e=t=>{for(let i of t)o.event({type:"ingested",source_id:i.source_id,status:i.status,cid:i.source_cid,...i.warnings?.length?{warnings:i.warnings}:{},...i.media?{media:i.media}:{},...i.duplicate_of?{duplicate_of:i.duplicate_of}:{},...i.lineage_candidate?{lineage_candidate:i.lineage_candidate}:{}})},m=o?{out:()=>{},err:(t,i)=>f.push({message:t.replace(/^error: /,""),...i?{code:i}:{}}),isTTY:!1,confirm:async()=>!1}:{out:t=>process.stdout.write(t+`
6
- `),err:t=>process.stderr.write(t+`
7
- `),isTTY:n,confirm:async t=>{let i=l({input:process.stdin,output:process.stdout});try{let h=await i.question(`${t} [Y/n] `);return!/^n(o)?$/i.test(h.trim())}finally{i.close()}}};if(!p){let{withTelemetry:t}=await import("./with-telemetry-LRI7H6DH.js");return t("ingest",async()=>{let{code:i,results:h}=await w(c,{as:s.as},m,void 0,void 0);if(i!==0)return i;let I=h.filter(Y=>Y.status!=="unchanged").length;return I>0&&(m.err??m.out)(`landed ${I} source(s) \u2014 run kane-cli context extract to extract them`),0},{write:!0})}let a;try{a=o?await(await import("./run-channel-RGH4WIQX.js")).runWithChannel({event:o.event},()=>w(c,{as:s.as},m,void 0,void 0)):await w(c,{as:s.as},m,void 0,void 0)}catch(t){if(o)return v(),o.event({type:"error",message:t instanceof Error?t.message:String(t),code:"INGEST_FAILED"}),o.done(1,"error");throw t}let{code:r,results:d}=a;if(r!==0)return o?(e(d),v(),o.done(r,r===2?"refused":"error")):r;if(d.length===0)return o?o.done(0):0;let{extractCommand:A}=await import("./extract-cmd-7FKQJNS7.js"),N=[...new Set(d.map(t=>t.source_id))],x=await A({...s.mode!==void 0?{mode:s.mode}:{},...s.plan?{plan:!0}:{},...s.force?{force:!0}:{},...s.trust!==void 0?{trust:s.trust}:{},sources:N,landed:d});if(x===2&&!g){let t=d.filter(i=>i.status!=="unchanged").length;t>0&&(m.err??m.out)(`note: the ${t} landed source(s) are safe \u2014 extract later with kane-cli context extract`)}return x}export{w as a,se as b,ie as c};
@@ -1,2 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{createHash as s}from"crypto";function f(n){if(n===null)return"null";let t=typeof n;if(t==="string")return JSON.stringify(n.normalize("NFC"));if(t==="boolean")return n?"true":"false";if(t==="number"){if(!Number.isFinite(n))throw new Error("non-finite number is not canonicalizable");return JSON.stringify(n)}if(Array.isArray(n))return"["+n.map(i=>i===void 0?"null":f(i)).join(",")+"]";if(t==="object"){let i=n,e=new Map;for(let r of Object.keys(i)){if(i[r]===void 0)continue;let o=r.normalize("NFC");if(e.has(o))throw new Error(`canonicalization collision: NFC-equivalent duplicate key ${JSON.stringify(o)}`);e.set(o,i[r])}return"{"+[...e.keys()].sort((r,o)=>Buffer.compare(Buffer.from(r,"utf8"),Buffer.from(o,"utf8"))).map(r=>JSON.stringify(r)+":"+f(e.get(r))).join(",")+"}"}throw new Error("unsupported type for canonicalization: "+t)}function a(n){return s("sha256").update(n).digest("hex")}export{f as a,a as b};
@@ -1,4 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{c as b,d as _}from"./chunk-NVGBE2DR.js";import{a as g,c as h}from"./chunk-UH2ZTX4E.js";import{j as S}from"./chunk-XMTSHHYQ.js";import{d as f,f as v}from"./chunk-AKX4VRRR.js";var V=n=>`conv#turn=${n}`;function E(n,o){for(let t of n.split(`
3
- `))if(t.trim())try{let r=JSON.parse(t);if(r.turn===o)return r.text}catch{}return null}var y={format:"conversation",media_type:"text/x-conversation",anchors_supported:["#turn="]};function $(n){let{contextDir:o,graph:t,sessionStamp:r}=n,e=`su-conv-${r}`,u=t.heads.get(e);if(typeof u=="string")return{record:null,errors:[{code:"CONV_SOURCE_EXISTS",detail:`${e} already exists \u2014 resume it`}],sourceId:e,cid:u};let i=b(o,Buffer.from("","utf8")),c=h(e,i),a=v("source",c);if(a.length>0)return{record:null,errors:a.map(s=>({code:s.code,detail:s.detail})),sourceId:e,cid:""};let d=g("source",c);return{record:S(o,{ts:new Date().toISOString(),proposal_id:null,nodes:[{cid:d,label:f.SOURCE,content:c}],edges:[],review:[],supersessions:[],source_head_moves:{[e]:d},media:{[e]:y},conv:{source_id:e,turn:0,append_of:null}},{expectPrev:t.latestHash}).record,errors:null,sourceId:e,cid:d}}function G(n){let{contextDir:o,graph:t,sourceId:r,text:e,force:u}=n,i=t.heads.get(r),c=t.convChains.get(r);if(typeof i!="string"||!c)return{record:null,errors:[{code:"CONV_SOURCE_MISSING",detail:`${r} is not a live conversation source`}]};let d=t.getNode(i)?.content?.blob;if(typeof d!="string")return{record:null,errors:[{code:"CONV_SOURCE_MISSING",detail:`${r} head node unreadable`}]};let l=_(o,d)?.toString("utf8")??"",s=c.turns;if(!u&&s>0&&E(l,s)===e)return{record:null,errors:null,turn:s,cid:i,idempotent:!0};let p=s+1,C=`${l}${JSON.stringify({turn:p,text:e})}
4
- `,O=b(o,Buffer.from(C,"utf8")),x=h(r,O),m=g("source",x);return{record:S(o,{ts:new Date().toISOString(),proposal_id:null,nodes:[{cid:m,label:f.SOURCE,content:x}],edges:[],review:[],supersessions:[],source_head_moves:{[r]:m},media:{[r]:y},conv:{source_id:r,turn:p,append_of:i}},{expectPrev:t.latestHash}).record,errors:null,turn:p,cid:m,idempotent:!1}}export{V as a,E as b,$ as c,G as d};
@@ -1,4 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{j as Re,k as oe,l as se,m as _e,n as $e,o as ae}from"./chunk-F5AI3UVS.js";import{a as te,c as re,d as ye,f as ie}from"./chunk-6AZNGOLH.js";import{a as P,b as we,d as ke}from"./chunk-OS4VSIHT.js";import{a as X,b as N,c as ee,d as W,e as he,g as O,h as ne}from"./chunk-W5TTF7GB.js";import{a as ge}from"./chunk-BZAGVBCX.js";import{d as ve}from"./chunk-6J5T5FEY.js";import{a as S}from"./chunk-O5U6EAL3.js";import{b as Z,c as J,d as Q}from"./chunk-T7DGNWI2.js";import{h as me,j as pe}from"./chunk-54JZ6VEW.js";import{C as I}from"./chunk-W3Z7AZNT.js";import{g as T}from"./chunk-XMTSHHYQ.js";import{existsSync as Oe,statSync as Ue}from"fs";import{basename as G,resolve as q}from"path";function Ee(e){if(!e||e.stale_refs.length===0)return"\u2014";let n=e.direct_refs??[];return`${e.stale_refs.length} stale${n.length>0?` \xB7 ${n.length} direct`:""}`}function ce(e,n){let t=[...e.rows.filter(a=>a.kind!=="REMOVE").map(a=>[a.kind,S(a.ref),a.reason,Ee(a.impact)]),...e.archive.map(a=>["ARCHIVE",S(a.ref),a.why,Ee(a.impact)])],r=Math.max(40,n??100),i=[`reconcile ${e.source_id} \u2014 head ${e.head.status} \xB7 ${t.length} decision${t.length===1?"":"s"}`];return t.length>0&&i.push(...ve(["kind","ref","why","impact"],t,r,2)),e.changed&&i.push(e.held?`extract ran in override mode; ${e.defaultsTaken??0} default(s) auto-taken; matched-but-changed and new proposals HELD for your verdict (staged \u2014 nothing committed)`:`extract ran in override mode; ${e.defaultsTaken??0} default(s) auto-taken; matched-but-changed proposals auto-committed as edits`),i.push("each row becomes a card below \u2014 verdicts commit as they land"),e.planPath&&i.push(`plan: ${e.planPath}`),i}var xe=new Set(["interactive","agent","ci","override"]);function Ae(e,n){if(e.mode!==void 0&&!xe.has(e.mode))return{error:`--mode must be interactive | agent | ci | override, got '${e.mode}'`,code:"MODE_USAGE"};let t=e.mode,r="reconcile without a TTY needs an explicit mode \u2014 pass --mode agent|ci|override, or --plan for a preview";return t==="interactive"&&!n?{error:r}:t||(n?"interactive":e.plan?"override":{error:r})}async function Pe(e){let{makeHeadlessIO:n,agentRefusal:t}=await import("./headless-io-66RG5NN5.js");return t(n("ndjson","reconcile"),e,"MODE_USAGE")}function Me(e,n,t,r){if(J(t)){let v=Q(t),s=v?.sourceIdFor(t)??null;if(v===null||s===null)return{error:`--from '${t}' is not a supported remote URL \u2014 supported: ${Z.map(u=>u.hint).join("; ")}`};if(r!==void 0&&r!==s)return{error:`--source-id '${r}' does not match this URL's own identity '${s}' \u2014 re-run without --source-id. A source adopted with --as updates by re-running context ingest with the same --as; reconcile follows only the URL's own id`};let c=I(e);if(!c.heads.has(s))return{error:`unknown source '${s}' \u2014 see \`kane-cli context list --type source\`. If this URL was ingested under a custom id, update it by re-running context ingest with the same --as`};if(c.heads.get(s)==null)return{error:`source '${s}' is retired \u2014 restore it first with \`kane-cli context revert\`, then reconcile`};let _=z(e,s,{remoteUrl:t});return _!==null?{error:_}:{sourceId:s,remoteUrl:t}}if(r===void 0)return{error:"reconcile needs --from <file> AND --source-id <id> \u2014 see `kane-cli context list --type source` for ids"};let i=q(n,t);if(!Oe(i)||!Ue(i).isFile())return{error:`--from '${t}' is not a file \u2014 pass the changed source document`};let a=me(i);if(!a.ok)return{error:`--from '${t}' is not an ingestable document \u2014 allowed: ${a.allowlist.join(", ")}`};let o=I(e);if(!o.heads.has(r))return{error:`unknown source '${r}' \u2014 see \`kane-cli context list --type source\``};if(o.heads.get(r)==null)return{error:`source '${r}' is retired \u2014 restore it first with \`kane-cli context revert\`, then reconcile`};let w=z(e,r,{filePath:i});if(w!==null)return{error:w};let f=null;try{f=pe(i)}catch{}return f!==null&&f!==r&&o.heads.get(f)!=null?{error:`'${G(i)}' already backs live source '${f}' \u2014 did you mean --source-id ${f}? To truly move these bytes under '${r}', retire '${f}' first`}:{sourceId:r,filePath:i}}function C(e){return e==null?"(none)":e.slice(0,19)}function Y(e,n,t,r=!1,i){if(e.out(`reconcile ${n.source_id}: head ${n.head.status} \u2014 ${C(n.head.before)} \u2192 ${C(n.head.after)}`),r||(e.out(`note: ${n.note}`),e.out(`skipped arms: ${n.skipped_arms}`)),n.changed&&(e.out(n.held?`extract ran in override mode; ${t?.defaultsTaken??0} default(s) auto-taken; matched-but-changed and new proposals HELD for your verdict (staged \u2014 nothing committed)`:`extract ran in override mode; ${t?.defaultsTaken??0} default(s) auto-taken; matched-but-changed proposals auto-committed as edits`),i?.({type:"defaults_taken",count:t?.defaultsTaken??0})),r){let a=n.changeset??[],o=(f,v)=>{let s=a.filter(c=>c.kind===f).length;return s>0?`${s} ${v}`:null},w=[o("ADD","add"),o("MODIFY","modify"),o("ARCHIVE","archive")].filter(Boolean);n.changed&&e.out(`changeset: ${a.length} item(s)${w.length?` \u2014 ${w.join(" \xB7 ")}`:""}`),e.out(`plan: ${n.rows.length} row(s) \u2014 each gets a card below`);return}if(n.changed){let a=n.changeset??[];e.out(`changeset: ${a.length} item(s)`);for(let o of a)if(o.kind==="MODIFY")e.out(` [MODIFY] ${S(o.ref)} \u2014 ${o.summary} (${C(o.old_cid)} \u2192 ${o.new_cid===null?"(staged)":C(o.new_cid)})`);else if(o.kind==="ADD")e.out(` [ADD] ${S(o.ref)}`);else{e.out(` [ARCHIVE] ${S(o.ref)} \u2014 ${o.why}`);let w=le(o.impact,"retiring drops");w&&e.out(` ${w}`)}}e.out(`plan: ${n.rows.length} row(s)`);for(let a of n.rows){e.out(` [${a.kind}] ${S(a.ref)} \u2014 ${a.reason}`);let o=le(a.impact,"approving marks");o&&e.out(` ${o}`),e.out(` provenance: ${a.provenance}`),e.out(` action: ${a.action}`)}}function De(e,n){return ce({source_id:e.source_id,head:{status:e.head.status},rows:e.rows,archive:(e.changeset??[]).filter(t=>t.kind==="ARCHIVE"),changed:e.changed,held:!!e.held,defaultsTaken:n?.defaultsTaken},process.stdout.columns)}function le(e,n){if(!e||e.stale_refs.length===0)return null;let t=e.direct_refs??[];return`impact: ${n} ${e.stale_refs.length} item(s) stale`+(t.length>0?` \u2014 ${t.length} directly touched: ${t.join(", ")}`:"")}function D(e){return e==="interactive"?"override":e}async function M(e,n,t,r,i,a,o=[],w="override",f,v,s,c,_,u,E){let m;try{m=ne(e)}catch(d){return P(r,d instanceof Error?d.message:String(d)),1}try{if(!t){let{runWalkSession:d}=await import("./walk-session-7JVB4Z5S.js"),{telemetryEnvName:R}=await import("./bootstrap-THOC3SS7.js");return await d({dir:e,rows:n,archive:o,held:f??null,childMode:w,runDesign:c??null,mark:a,markA:s,...v?{archiveState:v}:{},...u?{meta:{verb:"reconcile",sid:u,env:R()}}:{},...E?{resumeCmd:E}:{},signals:b=>U(e,b.ref,b.verdict,b.reason),..._?{script:_}:{}})}return await Te(e,n,t,r,i,a,o,w,f,v)}finally{m()}}var H=(e,n)=>e?`kane-cli maintain reconcile --from ${e} --source-id ${n}`:void 0,He=e=>e===null?void 0:"filePath"in e?e.filePath:e.remoteUrl,V=e=>`${e} high-risk item(s) need a human \u2014 ci mode won't guess. Walk interactively or use --mode agent.`;function F(e,n,t){let r=n.rows;e({type:"reconcile_plan",source_id:n.source_id,plan_path:t,rows:r.map(i=>({kind:i.kind,ref:i.ref,why:i.reason})),archive:n.changeset.filter(i=>i.kind==="ARCHIVE").map(i=>({ref:i.ref,why:i.why}))})}function de(e={}){return{type:"reconcile_summary",applied:0,skipped:0,deferred:0,plan_only:0,failed:0,paused:0,stale_created:0,...e}}var L=de();async function j(e,n,t,r,i,a,o,w,f){F(i,n,t);let v=n.changeset.filter(_=>_.kind==="ARCHIVE"&&f?.[_.ref]===void 0),s=n.rows,c;try{c=ne(e)}catch(_){return i({type:"error",message:_ instanceof Error?_.message:String(_)}),i(de()),2}try{return await Fe(e,n,t,r,i,a,o,s,v,w)}finally{c()}}async function Fe(e,n,t,r,i,a,o,w,f,v){let s=0,c=0,_=0,u=0,E=0,m=0,d=0,R=new Set,b=(h,p)=>{try{v?.(h,p)}catch{}};for(let[h,p]of w.entries()){i({type:"reconcile_row_start",kind:p.kind,ref:p.ref,...p.impact?{stale:p.impact.stale_refs.length,direct:p.impact.direct_refs?.length??0}:{}});let g=(l,$,x)=>i({type:"reconcile_row_end",kind:p.kind,ref:p.ref,outcome:l,...$!==void 0?{exit_code:$}:{},...x?{detail:x}:{}});if(p.applied){c++,g("skipped");continue}if(p.kind==="REMOVE"){E++,g("plan-only");continue}if(p.held_ref&&n.held){let l=new Set;if(p.kind==="MODIFY"&&p.impact){let x=I(e);for(let A of p.impact.stale_refs){let K=x.resolve(A);K&&x.stale(K.tip)==="fresh"&&l.add(A)}}let $=oe(e,n.held,p.held_ref,ue);if(!$.ok){_++,d===0&&(d=1),g("failed",1,$.message);continue}if($.kind==="ADD"){let x=await r($.ref,{yes:!0,mode:o});if(x!==0){x===3?(u++,d===0&&(d=3),g("paused",3)):(_++,d===0&&(d=1),g("failed",x));continue}}s++,$.kind!=="ADD"&&p.impact&&(m+=l.size),b(h,"approved"),U(e,p.ref,$.kind==="ADD"?"gap-resolved-create":"gap-resolved-evolve"),g("applied");continue}let y=te(I(e),p.ref);if(!y.ok){c++,g("skipped");continue}let k=y.target;if(R.has(k.ucTip)){c++,g("skipped");continue}if(p.kind==="ADD"){let l=await r(k.seamRef,{yes:!0,mode:o});if(l===3){u++,d===0&&(d=3),g("paused",3);continue}if(l!==0){_++,d===0&&(d=1),g("failed",l);continue}R.add(k.ucTip),s++,b(h,"approved"),U(e,p.ref,"gap-resolved-create"),g("applied")}else{let l=await re(e,k,{yes:!0,mode:o},a,r,"batch");l.outcome==="evolved"?(R.add(k.ucTip),s++,b(h,"approved"),U(e,p.ref,"gap-resolved-evolve"),g("applied")):l.outcome==="paused"?(u++,d===0&&(d=l.code),g("paused",l.code)):l.outcome==="failed"?(_++,d===0&&(d=1),g("failed",l.code)):(c++,g("skipped"))}}return f.length>0&&(i({type:"reconcile_paused",plan_path:t,pending:f.map(h=>({ref:h.ref,why:h.why}))}),u+=f.length,d===0&&(d=3)),i(de({applied:s,skipped:c,plan_only:E,failed:_,paused:u,stale_created:m})),d}var ue={kind:"human",id:process.env.USER??"operator"};function U(e,n,t,r){ge(e,{ts:new Date().toISOString(),command:"reconcile-walk",id:n,verdict:t,polarity:"preference",by:ue,target:n,...r!==void 0?{reason:r}:{}})}async function Te(e,n,t,r,i,a,o=[],w="override",f,v){let s=0,c=0,_=0,u=0,E=0,m=0,d=0,R=new Set;for(let[b,h]of n.entries()){if(h.applied){r.out(`skipped ${h.ref} \u2014 already applied (${h.applied.outcome} at ${h.applied.at})`),c++;continue}let p=l=>{try{a?.(b,l)}catch($){P(r,`could not record applied state for ${h.ref}: ${$ instanceof Error?$.message:String($)}`)}};if(h.kind==="REMOVE"){r.out(`REMOVE ${h.ref} \u2014 plan-only in this release (not executed)`),u++;continue}if(h.held_ref&&f){let l=oe(e,f,h.held_ref,ue);if(!l.ok){P(r,`held ${h.ref}: ${l.message}`),E++,d===0&&(d=1);continue}if(r.out(`committed ${l.ref} (${h.kind==="ADD"?"minted":"updated \u2014 old\u2192new redirect"})`),l.kind==="ADD"){let $=await i(l.ref,{yes:t,mode:w});if($===3){r.out(`design session for ${l.ref} paused \u2014 resume with the "kane-cli design tests --resume <session>" command printed above`),m++,d===0&&(d=3),p("approved");continue}if($!==0){P(r,`design run for ${l.ref} ended with exit code ${$}`),E++,d===0&&(d=1),p("approved");continue}}s++,p("approved"),U(e,h.ref,h.kind==="ADD"?"gap-resolved-create":"gap-resolved-evolve");continue}let g=I(e),y=te(g,h.ref);if(!y.ok){r.out(`skipped ${h.ref} \u2014 ${y.message}`),c++;continue}let k=y.target;if(R.has(k.ucTip)){r.out(`skipped ${h.ref} \u2014 use-case ${k.display} already handled in this walk`),c++;continue}if(h.kind==="ADD"){let l=await i(k.seamRef,{yes:t,mode:w});if(l===3){r.out(`design session for ${k.display} paused \u2014 resume with the "kane-cli design tests --resume <session>" command printed above; this row lands when that session completes`),m++,d===0&&(d=3);continue}if(l!==0){P(r,`design run for ${k.display} ended with exit code ${l}`),E++,d===0&&(d=1);continue}R.add(k.ucTip),s++,p("approved"),U(e,h.ref,"gap-resolved-create")}else{let l=await re(e,k,{yes:!0,mode:w},r,i,"batch");l.outcome==="evolved"?(R.add(k.ucTip),s++,p("approved"),U(e,h.ref,"gap-resolved-evolve")):l.outcome==="paused"?(m++,d===0&&(d=l.code)):l.outcome==="failed"?(E++,d===0&&(d=l.code)):c++}}for(let b of o)if(b.kind==="ARCHIVE"&&v?.[b.ref]===void 0){r.out(`[ARCHIVE] ${b.ref} \u2014 ${b.why}`);{let h=le(b.impact,"retiring drops");h&&r.out(` ${h}`)}r.out(" plan-only \u2014 retire belongs to the interactive session (never headless)"),u++}return r.out(`reconcile walk: ${s} applied, ${c} skipped, ${_} deferred, ${u} plan-only`+(E>0?`, ${E} failed`:"")+(m>0?`, ${m} paused`:"")),d}var Be=new Set(Z.map(e=>e.name));function z(e,n,t){let r=I(e),i=r.heads.get(n);if(i==null)return null;let a=r.mediaOf(i);if("remoteUrl"in t){let o=Q(t.remoteUrl)?.name??"remote";return a.format!==o?`source '${n}' is backed by ${a.format} content, not a ${o} source \u2014 reconcile it with the --from it was originally ingested from`:null}return Be.has(a.format)?`source '${n}' is a remote ${a.format} source \u2014 pass its URL to --from, not a file`:null}function fe(e,n,t,r){return"remoteUrl"in n?$e(e,n.remoteUrl,{out:t.out,err:t.err},r.remoteFindProvider):_e(e,n.filePath)}function Ie(e){return e.remote_url!==void 0?{remoteUrl:e.remote_url}:e.backing_path!==void 0?{filePath:e.backing_path}:null}async function Se(e,n,t,r,i,a=!1,o=!1){let w=i.seams??{reingest:fe(e,t,r,i),reextract:ae(e,{stage:a,hostOut:c=>r.out(c),hostEmit:c=>{c.type!=="run_start"&&i.emitEvent?.(c)},...i.emitEvent?{}:{hostProgress:c=>process.stderr.write(c+`
3
- `)}})},f=null,v={reingest:w.reingest,reextract:async c=>f=await w.reextract(c)},s;try{r.out(`reconciling ${n}: re-reading the source and comparing against the graph\u2026`),s=await(i.buildPlan??se)(e,n,v)}catch(c){return P(r,`reconcile failed: ${c instanceof Error?c.message:String(c)}`),null}if(s.changed)if(o)for(let c of De(s,f))r.out(c);else Y(r,s,f,!1,i.emitEvent);return s}async function Ve(e){let[{render:n},t,{ScrollbackProvider:r},{ChatSurface:i},{makeChatController:a},{makeReconcileDeps:o}]=await Promise.all([import("./build-JIKYOZUH.js"),import("./react-QWOAB3TB.js"),import("./scrollback-JLPJR25X.js"),import("./ChatSurface-B6ZIO3JL.js"),import("./chat-controller-YJCNU76T.js"),import("./reconcile-deps-ZBWUY3SM.js")]),w=t.default??t,f=a(),v=o({contextDir:e,note:s=>f.note(s)});return new Promise(s=>{let c=n(w.createElement(r,null,w.createElement(i,{controller:f,verb:"extract",reconcile:v,autoReview:!0,onReviewExit:()=>{c.unmount(),s(0)},onCtrlC:()=>{c.unmount(),s(v.pending()?3:0)}})),{exitOnCtrlC:!1})})}async function Le(e,n,t,r,i){let a=N(e,n);if("error"in a)return P(r,a.error),2;let{plan:o,path:w}=a,f=t==="override"||t==="ci";if(n===void 0&&t==="interactive"&&r.isTTY&&!await r.confirm(`apply plan ${G(w)} for ${o.source_id} (created ${o.created})?`))return r.out(`not applying ${G(w)}`),0;let v=i.runDesignForUc??ie,s=i.runDesignForUc??null,c=i.sessionScript,_=(h,p)=>O(w,h,p),u=(h,p)=>W(w,h,p),E=T(e);if(E===o.head_pin){if(t==="agent"){let p=i.emitEvent??(()=>{});return j(e,B(o),w,v,p,r,D(t),_,o.archive_state)}let h=ee(o);if(t==="ci"&&h.length>0)return P(r,V(h.length)),2;if(r.out(`applying stored plan ${G(w)} for ${o.source_id} (${o.rows.length} row(s))`),!f)for(let p of ce({source_id:o.source_id,head:{status:"stored plan"},rows:o.rows,archive:(o.changeset??[]).filter(g=>g.kind==="ARCHIVE"),changed:!1,held:!!o.held},process.stdout.columns))r.out(p);return M(e,o.rows,f,r,v,_,o.changeset??[],D(t),o.held,o.archive_state,u,s,c,o.source_id,H(o.backing_path??o.remote_url,o.source_id))}if(r.out(`graph moved since this plan (${C(o.head_pin)} \u2192 ${C(E)}) \u2014 recomputing`),o.held)return Ce(e,o,r,i,t,v,!1);let m=Ie(o);if(m===null)return P(r,`stored plan for ${o.source_id} names no backing file or URL \u2014 re-run reconcile --from`),2;let d=z(e,o.source_id,m);if(d!==null)return P(r,`stored plan cannot replay: ${d}`),2;let R=await Se(e,o.source_id,m,r,i,!1,t==="interactive");if(!R)return 1;if(!R.changed)return Y(r,R,null,!1,i.emitEvent),0;if(t==="agent"){let h=i.emitEvent??(()=>{});return j(e,R,null,v,h,r,D(t))}let b=R.changeset.filter(h=>h.kind==="ARCHIVE");return t==="ci"&&b.length>0?(P(r,V(b.length)),2):M(e,R.rows,f,r,v,void 0,R.changeset,D(t),R.held,void 0,void 0,s,c,R.source_id,H(He(m),R.source_id))}function B(e,n=!1){return{source_id:e.source_id,changed:!0,head:{status:"unchanged",before:e.head_pin,after:e.head_pin},note:e.note,skipped_arms:e.skipped_arms,changeset:e.changeset??[],rows:n?e.rows.filter(t=>t.applied===void 0):e.rows,...e.held?{held:e.held}:{}}}async function je(e,n,t,r,i,a,o){let w=r.runDesignForUc??null,f=r.sessionScript,v=he(e,n);if(v===null)return null;if("error"in v)return P(t,v.error),2;let{plan:s,path:c}=v,_=s.rows.filter(d=>d.applied===void 0),u=ee(s),E=r.emitEvent??(()=>{});if(_.length===0&&u.length===0){t.out(`already reconciled \u2014 plan ${s.created} applied ${s.rows.length} row(s)`);let d=ye(I(e)).staleCount;return d>0&&(t.out(`${d} item(s) still stale \u2014 kane-cli maintain evolve --from-stale`),E({type:"stale_debt",count:d})),i==="agent"&&(F(E,B(s),c),E({...L})),0}let m=T(e);return m!==s.head_pin?(t.out(`plan ${s.created} superseded \u2014 graph moved (${C(s.head_pin)} \u2192 ${C(m)}); recomputing`),Ce(e,s,t,r,i,a,o)):(t.out(`resuming plan ${s.created} \u2014 ${_.length} pending row(s)${u.length>0?`, ${u.length} undecided archive item(s)`:""}`),o?(Y(t,B(s),null,!1,r.emitEvent),t.out(`plan stored: ${c}`),i==="agent"&&(F(E,B(s),c),E({...L})),0):i==="agent"?j(e,B(s),c,a,E,t,D(i),(d,R)=>O(c,d,R),s.archive_state):i==="ci"&&u.length>0?(P(t,V(u.length)),2):M(e,s.rows,i==="override"||i==="ci",t,a,(d,R)=>O(c,d,R),s.changeset??[],D(i),s.held,s.archive_state,(d,R)=>W(c,d,R),w,f,s.source_id,H(s.backing_path??s.remote_url,s.source_id)))}async function Ce(e,n,t,r,i,a,o){let w=r.runDesignForUc??null,f=r.sessionScript,v;if(n.held){let g=I(e),y=new Set(n.rows.filter(l=>l.held_ref!==void 0&&l.applied!==void 0).map(l=>l.held_ref)),k=[];for(let l of n.held.rows){if(y.has(l.temp_ref))continue;if(!l.matched_cid){k.push(l);continue}let $=g.tipOf(l.matched_cid);if(g.superseded.get($)===null){t.out(`dropped held "${l.title}" \u2014 its use-case was retired meanwhile`),r.emitEvent?.({type:"held_dropped",ref:l.temp_ref,title:l.title,reason:"target_retired"});continue}k.push($===l.matched_cid?l:{...l,matched_cid:$,uc:{...l.uc,matches_existing:{cid:$}}})}v={source_id:n.held.source_id,rows:k}}let s=Ie(n);if(s===null)return P(t,`stored plan for ${n.source_id} names no backing file or URL \u2014 re-run reconcile --from`),2;let c=z(e,n.source_id,s);if(c!==null)return P(t,`stored plan cannot replay: ${c}`),2;let _=r.seams??{reingest:fe(e,s,t,r),reextract:ae(e,{stage:v!==void 0,hostOut:g=>t.out(g),hostEmit:g=>{g.type!=="run_start"&&r.emitEvent?.(g)},...r.emitEvent?{}:{hostProgress:g=>process.stderr.write(g+`
4
- `)}})},u;try{u=await(r.buildPlan??se)(e,n.source_id,_,{resumeHeld:v})}catch(g){return P(t,`reconcile failed: ${g instanceof Error?g.message:String(g)}`),1}if(i==="interactive"&&!o)for(let g of De(u,null))t.out(g);else Y(t,u,null,!1,r.emitEvent);let E=T(e),m=null;if(E!=null){let g={},y=new Set(u.changeset.filter(k=>k.kind==="ARCHIVE").map(k=>k.ref));for(let[k,l]of Object.entries(n.archive_state??{}))y.has(k)&&(g[k]=l);m=X(e,{version:2,source_id:u.source_id,...n.remote_url!==void 0?{remote_url:n.remote_url}:{backing_path:n.backing_path},head_pin:E,created:new Date().toISOString().replace(/[:.]/g,"-"),skipped_arms:u.skipped_arms,note:u.note,changeset:u.changeset,rows:u.rows,...u.held?{held:u.held}:{},...Object.keys(g).length>0?{archive_state:g}:{}}),t.out(`plan stored: ${m}`)}if(o){if(i==="agent"){let g=r.emitEvent??(()=>{});F(g,u,m),g({...L})}return 0}let d=r.emitEvent??(()=>{}),R=m?N(e,m).plan.archive_state:void 0,b=m?(g,y)=>O(m,g,y):void 0,h=m?(g,y)=>W(m,g,y):void 0;if(i==="agent")return j(e,u,m,a,d,t,D(i),b,R);let p=u.changeset.filter(g=>g.kind==="ARCHIVE"&&R?.[g.ref]===void 0);return i==="ci"&&p.length>0?(P(t,V(p.length)),2):M(e,u.rows,i==="override"||i==="ci",t,a,b,u.changeset,D(i),u.held,R,h,w,f,u.source_id,H(n.backing_path??n.remote_url,u.source_id))}async function be(e,n,t={},r=process.cwd()){let{telemetryBootstrap:i,telemetryEnvName:a}=await import("./bootstrap-THOC3SS7.js"),o=i({verb:"reconcile",mode:typeof e.mode=="string"?e.mode:"interactive",contextRoot:q(r,".context"),env:a(),applyPlanPath:typeof e.apply=="string"?q(r,e.apply):void 0,write:!0,longSession:!0});e.mode==="agent"&&t.emitEvent?.({type:"run_start",session:o.ids.session_id});let w=await Ye(e,n,t,r);return w===1&&e.mode!=="agent"&&(n.err??n.out)(o.supportFooter()),await o.end({exit_code:w}),w}async function Ye(e,n,t={},r=process.cwd()){let i=e.apply!==void 0&&e.apply!==!1,a=typeof e.apply=="string"?e.apply:void 0;if(e.plan&&i)return P(n,"pass --plan OR --apply, not both"),2;let o=e.from!==void 0||!i,w=e.from!==void 0&&J(e.from);if(o&&(!e.from||!e.sourceId&&!w))return P(n,"reconcile needs --from <file|url> AND --source-id <id> (files only \u2014 a URL derives its own id) \u2014 see `kane-cli context list --type source` for ids"),2;if(e.from&&a!==void 0)return P(n,"pass --from OR --apply <path>, not both \u2014 a stored plan names its own source"),2;let f=we(r,n);if(!f)return 2;if(e.mode!==void 0&&!xe.has(e.mode))return Pe(`--mode must be interactive | agent | ci | override, got '${e.mode}'`);let v=e.mode==="agent"||e.mode==="ci"||e.mode==="override";if(i&&!v&&!n.isTTY)return P(n,"refusing to apply without a TTY to confirm \u2014 pass --mode override|ci"),2;let s=!e.plan,c="override";if(e.from){let y=Ae(e,n.isTTY);if(typeof y=="object")return y.code==="MODE_USAGE"?Pe(y.error):(P(n,y.error),2);c=y}let _=c==="override"||c==="ci";if(i&&!e.from){let{makeReconcileDeps:y}=await import("./reconcile-deps-ZBWUY3SM.js"),k=a===void 0?y({contextDir:f}).pending():null;if(k?.kind==="cards"){let $=e.mode??"interactive";return!n.isTTY||$!=="interactive"?(P(n,`a held changeset for ${k.source} awaits review (${k.count} change(s)) \u2014 resume in a terminal: kane-cli maintain reconcile --apply [HELD_REVIEW]`),2):(t.cardApplyMount??Ve)(f)}let l=e.mode??"interactive";return Le(f,a===void 0?void 0:q(r,a),l,n,t)}let u=Me(f,r,e.from,e.sourceId);if("error"in u)return P(n,u.error),2;if(!i){let{sessionsHoldingSource:y}=await import("./sessions-GIEXOCE4.js"),{holders:k,corrupt:l}=y(f,u.sourceId);if(l>0)return P(n,`cannot verify review holds \u2014 ${l} session file(s) unreadable; inspect with kane-cli context sessions list, clean with kane-cli context sessions clean, then retry [SESSIONS_UNREADABLE]`),2;if(k.length>0)return P(n,`session ${k[0]} holds item(s) for review pinned to ${u.sourceId} \u2014 finish that review first: kane-cli context extract --resume ${k[0]} [SOURCE_HELD]`),2}if(c==="interactive"&&!e.plan&&!i){let y=t.seams?.reingest??fe(f,u,n,t),k;try{k=await y(u.sourceId)}catch($){return P(n,$ instanceof Error?$.message:String($)),1}let l=k.status==="unchanged"?null:Re(f,u.sourceId);if(k.status!=="unchanged"&&!l)return n.out(`${u.sourceId} landed for the first time \u2014 extract it: kane-cli context extract --source ${u.sourceId}`),0;if(l){let x=await(t.chatMount??(async A=>{let{bindExtractInteractive:K}=await import("./extract-bind-BFJPRNPQ.js");return K(A)}))({mode:"interactive",posture:"reconcile",source:u.sourceId,changeContext:l});if(x===3){let{sessionsHoldingSource:A}=await import("./sessions-GIEXOCE4.js");if(A(f,u.sourceId).holders.length===0)return 0}return x}}let E="remoteUrl"in u?{remoteUrl:u.remoteUrl}:{filePath:u.filePath},m=await Se(f,u.sourceId,E,n,t,!!e.plan||c==="interactive",c==="interactive"&&!e.plan);if(!m)return 1;let d=t.runDesignForUc??ie,R=t.runDesignForUc??null,b=t.sessionScript;if(!m.changed){let y=await je(f,u.sourceId,n,t,c,d,!!e.plan);if(y!==null)return y;if(Y(n,m,null,!1,t.emitEvent),c==="agent"){let k=t.emitEvent??(()=>{});F(k,m,null),k({...L})}return 0}let h=T(f),p=null;if(h!=null?p=X(f,{version:2,source_id:m.source_id,..."remoteUrl"in E?{remote_url:E.remoteUrl}:{backing_path:E.filePath},head_pin:h,created:new Date().toISOString().replace(/[:.]/g,"-"),skipped_arms:m.skipped_arms,note:m.note,changeset:m.changeset,rows:m.rows,...m.held?{held:m.held}:{}}):P(n,"no chain head after extract \u2014 plan not stored"),c==="agent"){let y=t.emitEvent??(()=>{});if(!s)return F(y,m,p),y({...L}),0;let k=p?(l,$)=>O(p,l,$):void 0;return j(f,m,p,d,y,n,D(c),k)}if(!s)return p&&n.out(`plan stored: ${p}`),0;let g=m.changeset.filter(y=>y.kind==="ARCHIVE");if(c==="ci"&&g.length>0)return p&&n.out(`plan stored: ${p}`),P(n,V(g.length)),2;if(p){n.out(`plan stored: ${p}`);let y=p;return M(f,Ke(f,y)??m.rows,_,n,d,(k,l)=>O(y,k,l),m.changeset,D(c),m.held,void 0,void 0,R,b,m.source_id,H(e.from,m.source_id))}return M(f,m.rows,_,n,d,void 0,m.changeset,D(c),m.held,void 0,void 0,R,b,m.source_id,H(e.from,m.source_id))}function Ke(e,n){let t=N(e,n);return"error"in t?null:t.plan.rows}async function dn(e,n={},t,r=process.cwd()){if(e.mode==="agent"){let{makeHeadlessIO:i}=await import("./headless-io-66RG5NN5.js"),a=t?i("ndjson","reconcile",t):i("ndjson","reconcile"),o={out:a.out,err:v=>a.event({type:"error",message:v}),isTTY:!1,confirm:async()=>!1,ask:async()=>""},{runWithChannel:w}=await import("./run-channel-RGH4WIQX.js"),f=2;try{f=await w({event:v=>a.event(v)},()=>be(e,o,{...n,emitEvent:v=>a.event(v)},r))}catch(v){f=1,a.event({type:"error",message:v instanceof Error?v.message:String(v)})}return a.done(f)}return be(e,ke(),n,r)}export{Ae as a,Me as b,D as c,U as d,be as e,dn as f};
@@ -1,26 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{d as w}from"./chunk-OTMAFCZK.js";import{b as h,c as b}from"./chunk-VZ7KXRXB.js";import{b as $}from"./chunk-IAHKTEET.js";var j=new Set(["delta","state-transition"]),K=/^capture baseline:/i;function I(e){return typeof e=="string"?e:e.text}function S(e){return typeof e=="object"&&e.baseline===!0||K.test(I(e).trim())}function T(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&"derived"in e}function B(e,r){if(e.check_prose)return e.check_prose;let t=r.find(o=>o.ref===e.check.verified_against),n=t?.text?` \u2014 the stated promise: ${t.text}`:"",s=String(e.check.operand??e.check.within??e.check.metric??"");return e.check.kind==="forbidden-presence"?`Confirm '${s}' does NOT appear (forbidden-presence)${n}`:`Confirm ${e.check.kind} check: ${s} (${e.check.operator})${n}`}var N=/^## Step \d+ — assert\s*$/;function X(e,r){let t=e.split(`
3
- `),n=!1;for(let s=0;s<t.length;s++){let o=/^(##\s.*?)\s@verifies\s+(.+?)\s*$/.exec(t[s]);if(!o)continue;n=!0;let c=o[2].split(",").map(a=>a.trim()).filter(Boolean).map(a=>{let i=r(a)??(a.startsWith("ac-")?a:null);if(!i)throw new Error(`@verifies ref '${a}' does not resolve to a committed AC`);return i});t[s]=`${o[1]} @verifies ${c.join(", ")}`}return{md:t.join(`
4
- `),tagged:n}}function Y(e,r){if(r.length!==0&&!e.split(`
5
- `).some(t=>/^##\s/.test(t)&&w.test(t)))throw new Error("generated body has no @verifies binding for its ACs \u2014 the emitter contract is broken")}function ee(e){let r=e.split(`
6
- `);if(r[0]?.trim()!=="---")return{};let t=r.slice(1).findIndex(n=>n.trim()==="---");if(t<0)return{};try{return h(r.slice(1,t+1).join(`
7
- `))??{}}catch{return{}}}function te(e,r){if(r.length===0)return e;let t=e.split(`
8
- `);for(let n=t.length-1;n>=0;n--){if(/^## Step \d+ — assert @verifies /.test(t[n]))return e;if(N.test(t[n]))return t[n]=`${t[n].trimEnd()} @verifies ${r.join(", ")}`,t.join(`
9
- `)}return e}function ne(e,r){return r.size===0?e:e.split(`
10
- `).map(t=>{let n=t.match(/^@import\s+(\S+)\s*$/);if(n&&r.has(n[1]))return`@import ${r.get(n[1])}`;let s=t.match(/^## Import: (\S+)\s*$/);return s&&r.has(s[1])?`## Import: ${r.get(s[1])}`:t}).join(`
11
- `)}function E(e){let r=e.expected_mode??(T(e.operand)?"runtime-derived":"inferred");return{kind:e.kind,operator:e.operator,...e.operand!==void 0?{operand:e.operand}:{},...j.has(e.kind)?{baseline:e.baseline??null}:{},...e.within!==void 0?{within:e.within}:{},...e.metric!==void 0?{metric:e.metric}:{},...e.threshold!==void 0?{threshold:e.threshold}:{},...e.unit!==void 0?{unit:e.unit}:{},verified_against:e.verified_against,expected_mode:r,review_required:e.review_required??r==="runtime-derived"}}function re(e,r,t){if(j.has(e.check.kind)&&!e.steps.some(S))throw new Error(`emitTestMd: check kind '${e.check.kind}' needs a baseline-capture step before the action (a step starting 'capture baseline: <metric>' or { baseline: true }) \u2014 the validator should have caught this`);let n=[];if(e.target){let i=u=>/^[A-Za-z0-9._/@-]+$/.test(u)?u:JSON.stringify(u);n.push("---",`target: ${e.target}`),e.app&&n.push(`app: ${i(e.app)}`),n.push("---","")}n.push(`# ${e.title}`,""),r.intent&&n.push(`> ${r.intent}`,"");for(let i of e.reuses??[])n.push(`## Import: ${i}`,"",`@import ${i}`,"");let s=[],o=e.steps.some(i=>typeof i=="object"&&(i.verifies?.length??0)>0),c=0;for(let i of e.steps){c++;let u=I(i).trim(),l=typeof i=="object"&&i.verifies?.length?` @verifies ${i.verifies.join(", ")}`:"";n.push(`## Step ${c}${l}`,"",u,""),s.push({step:c,objective:u,...S(i)?{baseline:!0}:{},...typeof i=="object"&&i.verifies?.length?{verifies:[...i.verifies]}:{}})}if(o){let i=-1;if(e.steps.forEach((u,l)=>{typeof u=="object"&&u.verifies?.includes(e.check.verified_against)&&(i=l)}),i<0)throw new Error(`emitTestMd: no tagged step claims check.verified_against (${String(e.check.verified_against)}) \u2014 the check would be dropped`);s[i].check=E(e.check)}else{c++;let i=B(e,t);n.push(`## Step ${c} \u2014 assert`,"",i,""),s.push({step:c,objective:i,check:E(e.check)})}let a=b({title:e.title,...r.title?{scenario:r.title}:{},objectives:s},{sortKeys:!0,lineWidth:-1});return{test_md:n.join(`
12
- `),objectives_yaml:a}}function ie(e){let t=e.replace(/\r\n/g,`
13
- `).split(`
14
- `).map(o=>o.replace(/[ \t]+$/,""));if(t[0]?.trim()==="---"){let o=t.slice(1).findIndex(c=>c.trim()==="---");if(o>=0){let c=h(t.slice(1,o+1).join(`
15
- `))??{},a="assurance"in c;delete c.assurance,Object.keys(c).length===0&&a?t=t.slice(o+2):t=["---",...b(c,{sortKeys:!0,lineWidth:-1}).trimEnd().split(`
16
- `),"---",...t.slice(o+2)]}}let n=[];for(let o of t)o===""&&n[n.length-1]===""||n.push(o);for(;n[0]==="";)n.shift();for(;n[n.length-1]==="";)n.pop();let s=n.join(`
17
- `)+`
18
- `;return"sha256:"+$(Buffer.from("assurance.testdef\0"+s,"utf8"))}import{existsSync as M,readFileSync as O}from"fs";import{dirname as W,isAbsolute as z,resolve as D}from"path";var _=/^@import\s+(\S+)\s*$/;function F(e){let r=new Set;for(let t=0;t<e.length;t++)if(_.test(e[t].trim()))for(let n=t-1;n>=0;n--){let s=e[n].trim();if(s!==""){s==="```"&&r.add(t);break}}return r}function G(e,r,t=new Set,n=0){if(n>10)return e;let s=e.split(`
19
- `),o=F(s);return s.map((c,a)=>{let i=_.exec(c.trim());if(!i||o.has(a))return c;let u=r(i[1]);if(!u||t.has(u.cycleKey))return c;let l=new Set(t);return l.add(u.cycleKey),G(u.body.trimEnd(),u.next,l,n+1)}).join(`
20
- `)}function q(e){return r=>{let t=e.resolve(r);if(!t)return null;let n=e.getNode(t.tip)?.content.test_md_blob;return n?{body:n,cycleKey:t.tip,next:q(e)}:null}}function V(e,r){return t=>{let n=z(t)?t:D(e,t);if(!M(n))return null;let s=O(n,"utf8"),o=P(s);return!o||!r.resolve(o)?null:{body:J(s),cycleKey:n,next:V(W(n),r)}}}function R(e,r){let t=-1;for(let d=1;d<r;d++)if(/^assurance\s*:\s*$/.test(e[d])){t=d;break}if(t<0)return null;let n=r;for(let d=t+1;d<r;d++)if(/^[^\s#]/.test(e[d])){n=d;break}let s,o=t,c,a,i,u,l,f=!1;for(let d=t+1;d<n;d++){let p=e[d].endsWith("\r")?e[d].slice(0,-1):e[d];if(p.trim()===""||/^\s*#/.test(p))continue;o=d;let v=/^(\s+)([^\s:#][^:]*):\s*(.*)$/.exec(p);if(!v){/^\s*["']?base["']?\s*:/.test(p)&&(f=!0);continue}let[,x,L,C]=v,m=L.trimEnd();s===void 0&&(s=x);let g=x===s,k=/^([^#\s]\S*)?\s*(#.*)?$/.exec(C.trim()),y=k?.[1];m==="id"&&g&&c===void 0&&(c=d,a=y),m==="base"&&(g&&i===void 0?(i=d,u=y,l=k?.[2]):g||(f=!0)),m!=="base"&&/^["']base["']$/.test(m)&&(f=!0)}return{start:t,lastChild:o,childIndent:s,idLine:c,id:a,baseLine:i,base:u,baseComment:l,strayBase:f}}function H(e){let r=A(e);if(!r)return null;let t=e.split(`
21
- `),n=R(t,r.endLine);return n?.id?{id:n.id,...n.base!==void 0?{base:n.base}:{}}:null}function P(e){return H(e)?.id??null}function A(e){let r=e.split(`
22
- `);if(r[0]?.trim()!=="---")return null;for(let t=1;t<r.length;t++)if(r[t].trim()==="---")return{text:r.slice(1,t).join(`
23
- `),endLine:t};return null}function J(e){let r=A(e);if(!r)return e;let t=e.split(`
24
- `),n=R(t,r.endLine),s=[],o=!1;for(let a=1;a<r.endLine;a++){let i=t[a];if(n&&a>=n.start&&a<=n.lastChild){o=!1;continue}if(/^assurance\s*:\s*\{/.test(i)){o=!0;continue}o&&/^\s+\S/.test(i)||(o=!1,s.push(i))}let c=t.slice(r.endLine+1).join(`
25
- `);return s.every(a=>a.trim()==="")?c:["---",...s,"---",c].join(`
26
- `)}export{T as a,X as b,Y as c,ee as d,te as e,ne as f,re as g,ie as h,_ as i,F as j,G as k,q as l,V as m,R as n,H as o,J as p};
@@ -1,16 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{h as _,k as M,m as R,o as h}from"./chunk-KO3FL2XW.js";import{x as k}from"./chunk-W3Z7AZNT.js";import{existsSync as j,mkdirSync as E,readdirSync as N,readFileSync as O,renameSync as T,writeFileSync as G}from"fs";import{join as g}from"path";var P=/^@import\s+(\S+)\s*$/;function W(e,n){let r=e.resolve(n),i=r?String(e.getNode(r.tip)?.content.title??""):"";return i&&k(i,()=>!1)||n}function D(e){return g(e,".testmuai","tests")}function L(e){let n=new Map;if(!j(e))return n;for(let r of N(e)){if(!r.endsWith("_test.md"))continue;let i=g(e,r);try{let s=h(O(i,"utf8"))?.id;s&&n.set(s,[...n.get(s)??[],i])}catch{}}return n}function q(e,n,r){let i=`assurance:
3
- id: ${n}
4
- base: ${r}
5
- `,s=e.endsWith(`
6
- `)?e:e+`
7
- `;return s.startsWith(`---
8
- `)?`---
9
- ${i}${s.slice(4)}`:s.startsWith(`---\r
10
- `)?`---\r
11
- ${i.replace(/\n/g,`\r
12
- `)}${s.slice(5)}`:`---
13
- ${i}---
14
- ${s}`}function z(e,n){let r=`${e}.tmp-mint`;G(r,n),T(r,e)}function V(e){let{graph:n,cids:r,cwd:i}=e,s=D(i),$=[],f=[],m=L(s),w=new Set,y=(t,d)=>{let a=m.get(t);if(a&&a.length>1)return f.push({id:t,reason:`two files claim assurance.id ${t}: ${a.join(" \xB7 ")} \u2014 resolve the duplicate first`}),null;if(w.has(t))return I(t);if(d.includes(t))return I(t)??`${W(n,t)}_test.md`;let S=n.resolve(t),b=S?n.getNode(S.tip):void 0,v=b?.content.test_md_blob,x=b?.content.definitionId;if(!v||!x)return f.push({id:t,reason:`${t} has no test definition in the graph`}),null;let A=v.split(`
15
- `).map(o=>{let c=P.exec(o.trim());if(!c)return o;let l=c[1];if(!n.resolve(l))return o;let F=y(l,[...d,t]);if(!F)throw new p(`dependency ${l} could not be minted/located`);return`@import ./${F}`}).join(`
16
- `),B=q(A,t,x),u=a?.[0];if(u){let o=O(u,"utf8"),c=h(o)?.base,l=_(M(o,R(s,n)));if(!c||l!==c)return f.push({id:t,reason:`${u} was edited since the engine last wrote it \u2014 keeping yours (reconcile via a run or maintain)`}),null}else{let o=W(n,t),c=g(s,`${o}_test.md`);for(let l=2;j(c);l++)c=g(s,`${o}-${l}_test.md`);u=c}return E(s,{recursive:!0}),z(u,B),w.add(t),m.set(t,[u]),$.push({id:t,path:u}),u.split("/").pop()},I=t=>m.get(t)?.[0]?.split("/").pop()??null;for(let t of r){let d=n.nameOf.get(t);if(!d){f.push({id:t,reason:"minted test has no logical id"});continue}try{y(d,[])}catch(a){if(a instanceof p)f.push({id:d,reason:a.message});else throw a}}return{wrote:$,refused:f}}var p=class extends Error{};export{D as a,L as b,V as c};
@@ -1,21 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{d as kt,g as xt}from"./chunk-QQ5MHSSY.js";import{b as y,c as me,d as ut,f as fe,g as ge}from"./chunk-5GUD3CIH.js";import{b as ve,c as K,d as ye,e as be}from"./chunk-K2UEVCIJ.js";import{a as lt,d as pt,h as L,i as mt,j as ft,k as U,l as gt,m as Z,n as _t,o as F,p as ht}from"./chunk-KO3FL2XW.js";import{d as Et}from"./chunk-NVGBE2DR.js";import{a as V,b as z,d as dt}from"./chunk-EHN5HTUD.js";import{a as re}from"./chunk-CH273NAE.js";import{d as _e}from"./chunk-OTMAFCZK.js";import{b as $,c as k}from"./chunk-VZ7KXRXB.js";import{a as le,c as st,d as at,e as ct,f as pe}from"./chunk-P7YZ3PU3.js";import{C as x,e as bt,f as wt}from"./chunk-W3Z7AZNT.js";import{b as G}from"./chunk-6FCPS2VT.js";import{a as yt}from"./chunk-UH2ZTX4E.js";import{b as he,d as ee,g as te,j as H}from"./chunk-XMTSHHYQ.js";import{d as q,f as vt}from"./chunk-AKX4VRRR.js";import{a as it,b as ot}from"./chunk-7GUFVQOQ.js";import{a as nt}from"./chunk-33GXXC2L.js";function D(e){if(e===null)return"broken";let t=Math.floor(e/100);return t===1?"passed":t===7?"failed":t===2?"skipped":"broken"}var C={failed:3,broken:2,passed:1,skipped:0};function we(e){let t="skipped";for(let r of e)C[r]>C[t]&&(t=r);return t}import{createHash as fr}from"crypto";import{basename as gr}from"path";function ke(e){let t=e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40);return t.length>0?t:"session"}function xe(e){return fr("sha256").update(e).digest("hex").slice(0,8)}function Ee(e){let t=gr(e).replace(/_test\.md$/i,"").replace(/\.md$/i,"");return`${ke(t)}-${xe(e)}`}function Ie(e,t){return`${ke(e)}-${xe(t)}`}function Se(e){let t=e?.trim();return t||void 0}function It(e=process.env){let t=Se(e.TEST_INSTANCE_ID),r=Se(e.JOB_ID),n=Se(e.TASK_ID);return{...t?{testInstanceId:t}:{},...r?{jobId:r}:{},...n?{taskId:n}:{}}}function Re(e,t=process.env){let r=It(t),n={...r.testInstanceId?{hyper_test_instance_id:r.testInstanceId}:{},...r.jobId?{hyper_job_id:r.jobId}:{},...r.taskId?{hyper_task_id:r.taskId}:{},...e},i={};for(let[o,s]of Object.entries(n))typeof s=="string"&&s.length>0&&(i[o]=s);return i}function _r(e,t){return{pack_test_dir:e,ordinal_offset:t}}import{promises as I}from"fs";import{join as S}from"path";function Ae(e){let t={evidence:"0.1",run_id:e.execution_id,status:"running",title:e.title,started:e.started,environment:{producer:{name:"kane-cli",version:e.producerVersion},...e.surfaces?{surfaces:e.surfaces}:{},run_kind:e.run_kind,origin:e.origin,pid:e.pid},...e.credits!==void 0?{metrics:{credits:{value:e.credits,type:"count"}}}:{}};return k(t,{lineWidth:-1})}async function Pe(e,t,r,n=process.cwd(),i){let o=i??y(e.execution_id,n),s=S(o,"tests",t);return await I.mkdir(S(o,"coverage"),{recursive:!0}),await I.writeFile(S(o,"coverage",".keep"),""),await I.mkdir(s,{recursive:!0}),await I.writeFile(S(o,"run.yaml"),Ae(e)),r&&await I.writeFile(S(s,r.path),r.content),o}async function hr(e,t=process.cwd()){let r=y(e.execution_id,t);await I.mkdir(S(r,"coverage"),{recursive:!0}),await I.writeFile(S(r,"coverage",".keep"),"");let n=$(Ae(e));return n.environment&&delete n.environment.run_kind,await I.writeFile(S(r,"run.yaml"),k(n,{lineWidth:-1})),r}async function vr(e,t=process.cwd()){return z(y(e,t),new Date().toISOString())}async function $e(e,t=process.cwd()){await I.rm(y(e,t),{recursive:!0,force:!0})}import{promises as Le}from"fs";import{join as Fe}from"path";function ne(e){let t={evidence:"0.1",test:e.testId,status:e.status,...e.durationMs!==void 0?{duration_ms:e.durationMs}:{},...e.attempts&&e.attempts.length?{attempts:e.attempts}:{},...e.flaky!==void 0?{flaky:e.flaky}:{},...e.adaptiveHeal?{adaptive_heal:e.adaptiveHeal}:{},...e.definitionPath?{definition:{path:e.definitionPath}}:{},...e.definitionId?{definition_id:e.definitionId}:{},...e.assuranceId?{assurance_id:e.assuranceId}:{},...Object.keys(e.externalId).length?{external_id:e.externalId}:{},...e.tags&&e.tags.length?{tags:e.tags}:{},...Object.keys(e.environment).length?{environment:e.environment}:{},steps:e.steps};return k(t,{lineWidth:-1})}function Ce(e){return k({logs:e},{lineWidth:-1})}async function De(e,t,r){await Le.writeFile(Fe(e,"tests",t,"result.yaml"),r)}async function je(e,t,r){let n=Fe(e,"tests",t,"logs");await Le.mkdir(n,{recursive:!0}),await Le.writeFile(Fe(n,"meta.yaml"),r)}import{promises as ie}from"fs";import{join as St}from"path";function Rt(e){return St(e,".internal","meta.json")}async function At(e){let t;try{t=await ie.readFile(Rt(e),"utf8")}catch(n){if(n?.code==="ENOENT")return null;throw n}let r=JSON.parse(t);if(!r||typeof r!="object"||Array.isArray(r))throw new Error("meta.json is not a JSON object");return r}async function Oe(e,t){let r;try{r=await At(e)??{}}catch(s){console.warn(`evidence: meta.json at ${e} unreadable \u2014 skipping execution-pointer append to preserve identity`,s);return}let n=Array.isArray(r.executions)?r.executions:[];n.push(t),r.executions=n,await ie.mkdir(St(e,".internal"),{recursive:!0});let i=Rt(e),o=`${i}.tmp-${process.pid}-${Date.now()}`;await ie.writeFile(o,JSON.stringify(r,null,2)+`
3
- `),await ie.rename(o,i)}async function yr(e){try{let t=await At(e);return t&&Array.isArray(t.executions)?t.executions:[]}catch{return[]}}async function br(e,t,r=process.cwd()){let n=await fe(e,r);if(!n){let o=`evidence: no pack found for "${e}"`;return t.json?console.log(JSON.stringify({valid:!1,error:"not_found",target:e})):console.error(o),2}let i=await V(n,t.profile??"L1");return t.json?console.log(JSON.stringify({valid:i.valid,status:i.status,diagnostics:i.diagnostics})):console.log(`evidence: ${i.valid?"valid":"INVALID"} (${t.profile??"L1"}, status ${i.status})`),i.valid?0:1}function Te(e){let t=[];for(let r of e){let n=r.perFlow&&r.perFlow.length?r.perFlow.map(i=>i.resultCode):[r.resultCode];for(let i of n)t.push(D(i))}return we(t)}function wr(e){let t=null;for(let r of e){let n=r.perFlow&&r.perFlow.length?r.perFlow.map(i=>i.resultCode):[r.resultCode];for(let i of n)i!=null&&(t==null||C[D(i)]>C[D(t)]||C[D(i)]===C[D(t)]&&i>t)&&(t=i)}return t}import{promises as kr}from"fs";import{extname as Pt,basename as xr}from"path";var Er={".ndjson":"ndjson",".log":"log",".json":"json",".har":"har"};async function Me(e){let t;try{t=await kr.readdir(e)}catch{return[]}return t.filter(r=>r!=="meta.yaml"&&!r.startsWith(".")).sort().map(r=>({name:xr(r,Pt(r)),file:r,format:Er[Pt(r)]??"txt"}))}import{mkdirSync as Ir,appendFileSync as Sr}from"fs";import{join as $t}from"path";function Ne(e,t){return $t(e,"tests",t,"logs")}function Be(e,t,r,n={},i){try{i?.(t,r,r,n)}catch{}if(e)try{Ir(e,{recursive:!0});let o=JSON.stringify({ts:new Date().toISOString(),level:t,event:r,...n})+`
4
- `;Sr($t(e,"diagnostics.ndjson"),o)}catch{}}import{promises as R}from"fs";import{dirname as jr,join as j}from"path";import{statSync as Rr}from"fs";import{promises as Ve}from"fs";import{basename as Ar,join as Pr}from"path";var $r=1e6,Lr=2e6;function Fr(){return it.map(e=>ot(e))}function Lt(e=Fr()){return e.map(t=>{let r=0;try{r=Rr(t).size}catch{}return{path:t,offset:r}})}var Cr=/\x1b\[[0-9;]*[A-Za-z]/g;async function Dr(e,t,r){let n;try{n=await Ve.open(e,"r");let i=(await n.stat()).size,o=t<=i?t:0,s=i-o;if(s<=0)return null;let c=s>r?i-r:o,u=Buffer.alloc(Math.min(s,r));return await n.read(u,0,u.length,c),u.toString("utf8")}catch{return null}finally{await n?.close().catch(()=>{})}}async function Ft(e,t){let r=t.caps?.stderr??$r,n=t.caps?.appium??Lr,i=[];t.runnerStderrPath&&i.push({src:t.runnerStderrPath,from:0,cap:r});for(let o of t.appiumMarks??[])i.push({src:o.path,from:o.offset,cap:n});for(let o of i){let s=await Dr(o.src,o.from,o.cap);if(s===null)continue;let c=s.replace(Cr,"");if(c!=="")try{await Ve.mkdir(e,{recursive:!0}),await Ve.writeFile(Pr(e,Ar(o.src)),c)}catch{}}}async function Or(e){try{let t=j(e,"tests"),r=await R.readdir(t).catch(()=>[]);for(let n of r){let i=j(t,n,"steps"),o=await R.readdir(i).catch(()=>[]);for(let s of o){let c=await R.readFile(j(i,s,"failure.yaml"),"utf8").catch(()=>null);if(c!=null)try{let u=$(c);if(u&&typeof u=="object"&&u.triage)return!0}catch{}}}}catch{}return!1}async function Ct(e,t,r,n={}){let i=j(e,"tests",t,"logs");if(r)try{await R.mkdir(i,{recursive:!0}),await R.copyFile(r,j(i,"tui.log"))}catch{}await Ft(i,{runnerStderrPath:r?j(jr(r),"runner-stderr.log"):void 0,appiumMarks:n.appiumMarks});let o=await Me(i);if(!o.length&&n.requireRealLog)throw new Error(`evidence test ${t} has no real log to declare`);o.length&&await je(e,t,Ce(o))}async function ze(e){let t=e.cwd??process.cwd(),r=e.packDir??y(e.executionId,t);if(!e.saved&&!e.packDir)return await $e(e.executionId,t),{sealed:!1};await Ct(r,e.testId,e.tuiLogPath,{requireRealLog:e.requireRealLog,appiumMarks:e.appiumMarks});let n=j(r,"run.yaml"),i=$(await R.readFile(n,"utf8"));i.environment={...i.environment??{},saved:e.saved,run_kind:e.runKind},await R.writeFile(n,k(i,{lineWidth:-1}));let o=await R.open(n,"r+");try{await o.sync()}finally{await o.close()}let s=await Or(r);await z(r,new Date().toISOString());let c;try{let a=await V(r,"L1");c=a.valid;let l=(a.diagnostics??[]).filter(d=>String(d?.code??"").includes("failure.status_disagrees"));if(l.length>0)if(e.expectStatusDisagrees||s){let d=e.expectStatusDisagrees?"expected under --bug-detection continue":"self-explained by triaged failure record(s)";console.warn(`evidence: ${l.length} status_disagrees advisory(ies) \u2014 ${d}`)}else console.warn(`evidence: ${l.length} status_disagrees advisory(ies) \u2014 step verdicts disagree with their failure records`,l);if(!a.valid){console.warn(`evidence: sealed pack ${e.executionId} failed L1 validation`,a.diagnostics);let d=String(a.diagnostics?.[0]?.code??"");Be(Ne(r,e.testId),"warn","EVIDENCE_INVALID",{execution_id:e.executionId,first_code:d,surface:e.surface??"testmd"},e.log)}}catch(a){console.warn(`evidence: validation error for ${e.executionId}`,a)}let u;if(e.saved&&e.packDir)try{u=await ut(r,e.executionId,t)}catch(a){console.warn(`evidence: store install failed for ${e.executionId}`,a)}if(e.outputStemDir)try{await Oe(e.outputStemDir,{execution_id:e.executionId,run_kind:e.runKind,status:e.verdict,valid:c,at:new Date().toISOString()})}catch(a){console.warn(`evidence: execution-pointer append failed for ${e.executionId} (pack is sealed)`,a)}return{sealed:!0,valid:c,storePath:u}}import{release as Mt}from"os";import{execFileSync as Tr}from"child_process";import{promises as Dt}from"fs";import{join as jt}from"path";function Ot(e){return e.replace(/\([^)]*\)/g," ").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||void 0}async function Tt(e){try{let t=jt(e,"steps"),r=(await Dt.readdir(t,{withFileTypes:!0})).filter(n=>n.isDirectory()).map(n=>n.name).sort((n,i)=>(parseInt(n,10)||0)-(parseInt(i,10)||0));for(let n of r)try{let i=await Dt.readFile(jt(t,n,"step.json"),"utf8"),s=JSON.parse(i).basis?.window;if(Array.isArray(s)&&s.length===2&&Number.isFinite(Number(s[0]))&&Number.isFinite(Number(s[1]))&&Number(s[0])>0&&Number(s[1])>0)return`${Math.round(Number(s[0]))}x${Math.round(Number(s[1]))}`}catch{}return}catch{return}}var Nt=!1,oe;function Mr(){if(!Nt)if(Nt=!0,process.platform==="darwin")try{oe=Tr("sw_vers",["-productVersion"],{timeout:2e3}).toString().trim()||void 0}catch{oe=Mt()||void 0}else oe=Mt()||void 0;return oe}function Ue(e){let t={os:le(process.platform)},r=Mr();if(r&&(t.os_version=r),e.cdpBrowser){let i=/^([A-Za-z]+)\/(\d+)/.exec(e.cdpBrowser);i&&(t.browser=i[1].replace(/^Headless/,""),t.browser_version=i[2])}e.resolution&&(t.resolution=e.resolution);let n=at(t,e.runnerEnvironment);if(!n.native_platform)return n;if(e.deviceName&&(n.device=e.deviceName),e.deviceModel){let i=Ot(e.deviceModel);i&&(n.device_slug=i)}return e.pixelResolution&&(n.viewport=n.resolution??Nr(e.pixelResolution,n.pixel_ratio)??e.pixelResolution,n.resolution=e.pixelResolution),n}function Nr(e,t){if(!t||!Number.isFinite(t)||t<=0)return;let r=/^(\d+)x(\d+)$/.exec(e);if(r)return`${Math.round(Number(r[1])/t)}x${Math.round(Number(r[2])/t)}`}async function Bt(e){if(e)try{let t=await fetch(`${e}/json/version`,{signal:AbortSignal.timeout(2e3)});if(!t.ok)return;let r=await t.json();return typeof r.Browser=="string"?r.Browser:void 0}catch{return}}function Br(e){let t;return()=>(t||(t=Bt(e)),t)}import{promises as b,existsSync as A,readFileSync as qr}from"fs";import{basename as Hr,join as _}from"path";import{readFileSync as Vr}from"fs";import{dirname as zr,resolve as Ur}from"path";function Vt(e,t){let r=Ur(e),n=Vr(r,"utf8");return L(t?U(n,Z(zr(r),t)):n)}async function zt(e){for(let t of await b.readdir(e,{withFileTypes:!0})){let r=_(e,t.name);if(t.isDirectory()){await zt(r);continue}try{await b.unlink(r)}catch{await b.truncate(r,0)}}await b.rmdir(e).catch(()=>{})}function Gr(e){let t=e.authorBoundary<0||e.authorBoundary>e.totalSteps?e.totalSteps:e.authorBoundary;return{shrink_count:e.shrinkCount,complete_reauthor:t===0&&e.totalSteps>0,author_boundary:t,total_steps:e.totalSteps,reauthored_steps:e.totalSteps-t,credits_consumed:Math.round(e.creditsConsumed*100)/100}}var W=class e{constructor(t){this.opts=t}executionId;testId;definitionPath=null;definitionContent=null;accumulatedSteps=[];maxOrdinal=0;_attempts=[];_packDirOverride;_attached=!1;appiumMarks=Lt();get attached(){return this._attached}static async attach(t){let r=Hr(t.packDir).replace(/\.evidence$/,""),n=new e({origin:"testrun",runKind:"author",pid:process.pid,title:t.testId,started:new Date().toISOString(),producerVersion:nt,cwd:t.cwd});n.executionId=r,n.testId=t.testId,n._packDirOverride=t.packDir,n._attached=!0;let i=_(t.packDir,"tests",t.testId);return await b.mkdir(i,{recursive:!0}),t.definition&&(await b.writeFile(_(i,t.definition.path),t.definition.content),n.definitionPath=t.definition.path,n.definitionContent=t.definition.content),n}async start(){if(this._attached)throw new Error("attach-mode session is already started");this.executionId=me(),this.testId=this.opts.testmdRelPath?Ee(this.opts.testmdRelPath):Ie(this.opts.objectiveOrName??"session",this.opts.sessionId??this.executionId);let t=this.opts.definition??null;return await Pe({execution_id:this.executionId,title:this.opts.title,started:this.opts.started,producerVersion:this.opts.producerVersion,surfaces:this.opts.surfaces,run_kind:this.opts.runKind,origin:this.opts.origin,pid:this.opts.pid,...this.opts.credits!==void 0?{credits:this.opts.credits}:{}},this.testId,t,this.opts.cwd,this.opts.packRootDir?this.pack:void 0),t&&(this.definitionPath=t.path,this.definitionContent=t.content),{executionId:this.executionId,testId:this.testId,packTestDir:this.packTestDir}}get pack(){return this._packDirOverride?this._packDirOverride:this.opts.packRootDir?_(this.opts.packRootDir,`${this.executionId}.evidence`):y(this.executionId,this.opts.cwd)}get packTestDir(){return _(this.pack,"tests",this.testId)}async writeDefinition(t,r="test.md"){await b.writeFile(_(this.packTestDir,r),t),this.definitionPath=r,this.definitionContent=t}computeAssuranceId(){try{if(this.opts.testmdRelPath&&this.opts.cwd){let t=_(this.opts.cwd,this.opts.testmdRelPath);if(A(t))return F(qr(t,"utf8"))?.id}}catch{}}computeDefinitionId(){try{if(this.opts.testmdRelPath&&this.opts.cwd){let t=_(this.opts.cwd,this.opts.testmdRelPath),r=_(this.opts.cwd,".context"),n=A(r)?x(r):void 0;if(A(t))return Vt(t,n)}if(this.definitionContent!=null)return L(this.definitionContent)}catch{}}noteSpawn(t){this.accumulatedSteps.push(...t.steps),this.maxOrdinal=Math.max(this.maxOrdinal,t.maxOrdinal)}nextOrdinalOffset(){return this.maxOrdinal}get steps(){return this.accumulatedSteps}get attempts(){return this._attempts}async archiveAttempt(t,r,n={}){let i=this._attempts.length+1,o=_(this.packTestDir,String(i)),s=n.log,c=(a,p)=>s?.("warn","ARCHIVE_ATTEMPT_FAILED",`Attempt ${i}: ${a} could not be archived into ${i}/; the next attempt will mingle with it`,{attempt:i,dir:a,error:String(p)}),u;try{await b.mkdir(o,{recursive:!0})}catch(a){c(`${i}/`,a)}for(let a of["steps","logs","v16-trajectory"]){let p=_(this.packTestDir,a);if(!A(p))continue;let l=_(o,a);try{await b.rename(p,l);continue}catch(d){s?.("warn","ARCHIVE_ATTEMPT_RENAME_FAILED",`Attempt ${i}: rename of ${a}/ refused; copying it into ${i}/ and emptying the originals in place`,{attempt:i,dir:a,error:String(d),fallback:"copy+truncate"})}try{await b.cp(p,l,{recursive:!0}),await zt(p)}catch(d){c(a,d)}}try{this.definitionPath&&A(_(this.packTestDir,this.definitionPath))&&await b.copyFile(_(this.packTestDir,this.definitionPath),_(o,this.definitionPath));let a=_(o,"steps");if(A(a)){for(let p of await b.readdir(a))if(A(_(a,p,"failure.yaml"))){u=`${i}/steps/${p}/failure.yaml`;break}}}catch(a){c("definition + failure pointer",a)}return this._attempts.push({n:i,status:t,steps:this.accumulatedSteps,...r!==void 0?{failedAt:r}:{},...u?{failure:u}:{}}),this.accumulatedSteps=[],this.maxOrdinal=0,i}async writeResult(t){let r=Te(t.spawns),n=this._attempts.length?[...this._attempts.map(m=>({status:m.status})),{status:r,...t.durationMs!==void 0?{duration_ms:t.durationMs}:{}}]:void 0,i=n?new Set(n.map(m=>m.status)).size>1:void 0,o=this._attempts.length>0,s=t.heal,c=o||s?.forced?{triggered:o,...o?{outcome:r==="passed"?"healed":"exhausted"}:{},...s?Gr(s):{},...o?{attempts:this._attempts.map(m=>({n:m.n,status:m.status,failed_at:m.failedAt??-1,...m.failure?{failure:m.failure}:{}}))}:{}}:void 0,u=this.pack,a=Re(t.externalIdInput),p=pe(t.runnerEnv,t.intentEnv),l=this.computeDefinitionId(),d=this.computeAssuranceId();await De(u,this.testId,ne({testId:this.testId,status:r,durationMs:t.durationMs,definitionPath:this.definitionPath,definitionId:l,assuranceId:d,externalId:a,environment:p,steps:t.steps,tags:t.tags,attempts:n,flaky:i,adaptiveHeal:c}));for(let m of this._attempts){let g=_(this.packTestDir,String(m.n));A(g)&&await b.writeFile(_(g,"result.yaml"),ne({testId:this.testId,status:m.status,definitionPath:this.definitionPath,definitionId:l,assuranceId:d,externalId:a,environment:p,steps:m.steps,tags:t.tags}))}let f=t.externalIdInput;return t.log&&(f.commit_id||f.test_id||f.testcase_id)&&t.log("info","EVIDENCE_EXTERNAL_ID","Evidence external-id mapping",{execution_id:this.executionId,commit_id:f.commit_id??null,test_id:f.test_id??null,testcase_id:f.testcase_id??null,project_id:f.project_id??null,session_id:f.session_id??null,session_name:f.session_name??null,hyper_test_instance_id:a.hyper_test_instance_id??null,hyper_job_id:a.hyper_job_id??null,hyper_task_id:a.hyper_task_id??null}),r}get id(){return this.executionId}get test(){return this.testId}};async function Kr(e,t,r=ge){try{let n=await r(e);if(n.aborted.length>0||n.removed.length>0)try{t?.("info","EVIDENCE_RECOVERY","Startup evidence recovery swept incomplete packs",{aborted:n.aborted,removed:n.removed,origin:"startup"})}catch{}return n}catch(n){return console.warn("evidence: startup recovery failed",n),{aborted:[],removed:[]}}}import{promises as _n}from"fs";import{existsSync as Ke,mkdirSync as dn,readdirSync as un,readFileSync as ln,rmSync as pn,statSync as mn,writeFileSync as fn}from"fs";import{join as M}from"path";import{mkdirSync as Wr,renameSync as Yr,rmSync as Jr,writeFileSync as Xr}from"fs";import{join as Ut}from"path";var Qr=5e6;function qt(e,t,r){let n=Ut(e,"coverage","sources"),i=new Map,o=!1;try{for(let s of r.usecases)for(let c of s.sources){if(i.has(c.id)){c.file=i.get(c.id);continue}if(!c.cid)continue;let u=Et(t,c.cid);if(u===null||u.byteLength>Qr)continue;o||(Wr(n,{recursive:!0}),o=!0);let a=Ut(n,c.id),p=`${a}.tmp-${process.pid}`;Xr(p,u),Yr(p,a);let l=`coverage/sources/${c.id}`;i.set(c.id,l),c.file=l}}catch{for(let s of r.usecases)for(let c of s.sources)delete c.file;if(o)try{Jr(n,{recursive:!0,force:!0})}catch{}}}import{appendFileSync as Zt,existsSync as O,readFileSync as P,renameSync as er,writeFileSync as tr}from"fs";import{dirname as He,isAbsolute as ae,join as T,resolve as ce}from"path";var Zr=new Set(["inline","testmd","testrun"]),en=new Set(["inferred","authored","runtime-derived"]),se=new Set(["passed","failed","broken","skipped"]);function Ht(e,t,r){if(r.facts.length===0)return{record:null,errors:[{code:"EMPTY_EXECUTIONS",detail:"a run with no designed units attaches no facts \u2014 skip the call"}]};let n=t;for(let i=0;;i++){let o=te(e);if(n.latestHash!==o){if(i>=3)return{record:null,errors:[{code:"STALE_BASIS",detail:`graph opened at ${String(n.latestHash)} but chain head is ${String(o)} \u2014 retry budget exhausted`}]};n=x(e);continue}let s=tn(e,n,r);if(s!=="cas")return s;if(i>=3)return{record:null,errors:[{code:"STALE_BASIS",detail:"concurrent appends kept moving the head \u2014 retry budget exhausted"}]};n=x(e)}}function Gt(e,t){return Zr.has(e.mode)?se.has(e.verdict)?en.has(e.oracle_mode)?typeof e.drift_flag!="boolean"||typeof e.stale_at_run!="boolean"?[{code:"MISSING_FIELD",detail:`${t}: drift_flag and stale_at_run are required booleans`}]:!e.execution_id||!e.started_at||!e.definition_id_at_run?[{code:"MISSING_FIELD",detail:`${t}: execution_id, started_at and definition_id_at_run are required`}]:[]:[{code:"BAD_ORACLE_MODE",detail:`${t}: oracle_mode '${e.oracle_mode}' not in inferred|authored|runtime-derived`}]:[{code:"BAD_VERDICT",detail:`${t}: verdict '${e.verdict}' not in ${[...se].join("|")}`}]:[{code:"BAD_MODE",detail:`${t}: mode '${e.mode}' not in inline|testmd|testrun`}]}function Kt(e,t,r,n){return{about:t,definition_id_at_run:e.definition_id_at_run,verdict:e.verdict,...r&&r.length?{per_ac:r}:{},drift_flag:e.drift_flag,oracle_mode:e.oracle_mode,stale_at_run:e.stale_at_run,...n.length?{unresolved_acs:n}:{},execution_id:e.execution_id,...e.evidence_id?{evidence_id:e.evidence_id}:{},...e.duration_ms!==void 0?{duration_ms:e.duration_ms}:{},started_at:e.started_at,mode:e.mode,local:e.local,...e.via_parent?{via_parent:e.via_parent}:{}}}function Wt(e,t){if(!Array.isArray(t.facts)||t.facts.length===0)return{record:null,errors:[{code:"EMPTY_EXECUTIONS",detail:"parked line carries no facts"}]};for(let r=0;;r++){let n=x(e),i=t.facts.filter(a=>n.appliedEvents.has(a.event_id)).map(a=>a.event_id),o=t.facts.filter(a=>!n.appliedEvents.has(a.event_id));if(o.length===0)return{record:null,errors:null,applied:[],skipped:i,rejected:[]};let s=[],c=[],u=[];for(let a of o){let p=`executions[${a.ref}]`,l=[];if(!a.about_cid||!n.hasNode(a.about_cid))l.push({code:"UNKNOWN_REF",detail:`${p}: about_cid '${String(a.about_cid)}' is not in the graph \u2014 the pinned run-time target is gone`});else if(n.nodeLabel.get(a.about_cid)!==q.TEST)l.push({code:"ILLEGAL_TARGET",detail:`${p}: execution facts attach to tests \u2014 '${a.about_cid}' is a ${n.nodeLabel.get(a.about_cid)}`});else if(!a.event_id)l.push({code:"MISSING_FIELD",detail:`${p}: parked facts require event_id`});else{l.push(...Gt(a,p));for(let m of a.per_ac??[])se.has(m.verdict)||l.push({code:"BAD_VERDICT",detail:`${p}.per_ac['${m.ac_ref}']: verdict '${m.verdict}'`})}if(l.length>0){s.push({event_id:a.event_id??"",errors:l});continue}let d=[],f=[...a.unresolved_acs??[]];for(let m of a.per_ac??[]){let g=n.resolve(m.ac_ref),w=g?n.tipOf(g.cid):null;if(!g||!w||n.superseded.has(w)||n.nodeLabel.get(w)!==q.AC){f.push(m.ac_ref);continue}d.push({ac_ref:n.nameOf.get(w)??w,verdict:m.verdict})}c.push(Kt(a,a.about_cid,d,f)),u.push(a.event_id)}if(c.length===0)return{record:null,errors:null,applied:[],skipped:i,rejected:s};try{let a=H(e,{ts:new Date().toISOString(),proposal_id:null,nodes:[],edges:[],review:[],supersessions:[],executions:c,event_ids:[...u].sort(),source_head_moves:{}},{expectPrev:n.latestHash,busyRetry:{deadlineMs:5e3}}),p;try{G(e)}catch(l){p=`parked facts committed, but the projection refresh failed (${l instanceof Error?l.message:String(l)}) \u2014 read state rebuilds on the next open`}return{record:a.record,errors:null,applied:u,skipped:i,rejected:s,...p?{warnings:[p]}:{}}}catch(a){if(!(a instanceof he))throw a;if(r>=3)return{record:null,errors:[{code:"STALE_BASIS",detail:"concurrent appends kept moving the head \u2014 parked replay retry budget exhausted (line stays queued)"}]}}}}function tn(e,t,r){let n=[],i=[];for(let c of r.facts){let u=`executions[${c.ref}]`,a=t.resolve(c.ref),p=a?t.tipOf(a.cid):null;if(!a||!p||t.superseded.has(p)){n.push({code:"UNKNOWN_REF",detail:`${u}: '${c.ref}' is not a live committed node`});continue}if(t.nodeLabel.get(p)!==q.TEST){n.push({code:"ILLEGAL_TARGET",detail:`${u}: execution facts attach to tests \u2014 '${c.ref}' is a ${t.nodeLabel.get(p)}`});continue}let l=Gt(c,u);if(l.length>0){n.push(...l);continue}let d=[];for(let f of c.per_ac??[]){let m=t.resolve(f.ac_ref),g=m?t.tipOf(m.cid):null;if(!m||!g||t.superseded.has(g)||t.nodeLabel.get(g)!==q.AC){n.push({code:"UNKNOWN_REF",detail:`${u}.per_ac: '${f.ac_ref}' is not a live AC`});continue}if(!se.has(f.verdict)){n.push({code:"BAD_VERDICT",detail:`${u}.per_ac['${f.ac_ref}']: verdict '${f.verdict}'`});continue}d.push({ac_ref:t.nameOf.get(g)??g,verdict:f.verdict})}i.push(Kt(c,p,d,c.unresolved_acs??[]))}if(n.length>0)return{record:null,errors:n};let o;try{o=H(e,{ts:new Date().toISOString(),proposal_id:null,nodes:[],edges:[],review:[],supersessions:[],executions:i,...r.eventIds&&r.eventIds.length>0?{event_ids:r.eventIds}:{},source_head_moves:{}},{expectPrev:t.latestHash,busyRetry:{deadlineMs:r.lockDeadlineMs??5e3}})}catch(c){if(c instanceof he)return"cas";throw c}let s;try{G(e)}catch(c){s=`facts committed, but the projection refresh failed (${c instanceof Error?c.message:String(c)}) \u2014 read state rebuilds on the next open`}return{record:o.record,errors:null,...s?{warnings:[s]}:{}}}function rr(e){let t={failed:3,broken:2,skipped:1,passed:0},r=new Map;for(let n of e)for(let i of n.verifies??[]){let o=r.get(i);(o===void 0||(t[n.status]??0)>(t[o]??0))&&r.set(i,n.status)}return[...r.entries()].map(([n,i])=>({ref:n,verdict:i}))}function nr(e){let t=[],r=re(e.cwd);if(!O(r))return{synced:0,superseded:0,skipped:"no-context",warnings:t};let n=e.by??{kind:"ai",id:"exec-sync"},i=e.lockDeadlineMs;try{rn(r,t,i)}catch(d){t.push(`sync: parked-facts replay failed (${d instanceof Error?d.message:String(d)}) \u2014 queue intact, retrying next sync`)}let o=x(r),s=[],c=0,u=new Set,a=new Set(e.members.map(d=>ae(d.path)?d.path:ce(e.cwd,d.path))),p=new Map;for(let d of e.members){let f=ae(d.path)?d.path:ce(e.cwd,d.path);if(!O(f)){t.push(`sync: member file missing: ${f} \u2014 skipped, no fact attached`);continue}for(let m of nn(f,t))if(!u.has(m.path))try{let g=m.path===f,w=!g&&a.has(m.path),h=g?void 0:F(P(f,"utf8"))?.id,Y=P(m.path,"utf8"),E=F(Y);if(!E?.id){u.add(m.path);continue}let ue=o.resolve(E.id),N=ue?o.tipOf(ue.cid):null;if(!ue||!N||o.superseded.has(N)){u.add(m.path),t.push(`sync: ${E.id} does not resolve to a live test \u2014 skipped (foreign store?)`);continue}let J=L(U(Y,Z(He(m.path),o))),mr=String(o.getNode(N)?.content.test_md_blob??""),X=L(U(mr,gt(o))),B=!1,Q=N;if(J===X)E.base!==X&&Qt(m.path,Y,X,t);else if(E.base===X){let v=sn(r,o,N,Y,J,He(m.path),n);v.error?(t.push(`sync: could not supersede ${E.id}: ${v.error}`),B=!0):(c++,Q=v.newCid,B=v.oracleTier,Qt(m.path,P(m.path,"utf8"),J,t),o=x(r))}else B=!0,t.push(E.base?`sync: ${E.id} was edited from an older version \u2014 graph kept; reconcile via a redesign or maintain`:`sync: ${E.id} carries no base pin (hand-copied file?) \u2014 fact attached with drift flag`);if(w){B&&p.set(m.path,!0);continue}u.add(m.path);let Ze=o.getNode(Q)?.content.check,et=g?d.acs??[]:[],tt=et.filter(v=>Jt(o,v.ref)),rt=et.filter(v=>!Jt(o,v.ref)).map(v=>v.ref);s.push({ref:E.id,about_cid:Q,definition_id_at_run:J,verdict:d.verdict,...tt.length?{per_ac:tt.map(v=>({ac_ref:v.ref,verdict:v.verdict}))}:{},drift_flag:B||p.get(m.path)===!0||g&&d.driftFlag===!0,oracle_mode:Ze?.expected_mode??(lt(Ze?.operand)?"runtime-derived":"inferred"),stale_at_run:o.stale(Q)!=="fresh",...rt.length?{unresolved_acs:rt}:{},execution_id:d.executionId,...d.evidenceId?{evidence_id:d.evidenceId}:{},...d.durationMs!==void 0?{duration_ms:d.durationMs}:{},started_at:d.startedAt,mode:d.mode,local:d.local,...h?{via_parent:h}:{}})}catch(g){m.path!==f&&a.has(m.path)||u.add(m.path),t.push(`sync: ${m.path} failed to sync (${g instanceof Error?g.message:String(g)}) \u2014 skipped; other members unaffected`)}}if(s.length===0)return{synced:0,superseded:c,warnings:t};let l;try{l=Ht(r,x(r),{facts:s,by:n,lockDeadlineMs:i})}catch(d){return t.push(`sync facts: commit threw: ${d instanceof Error?d.message:String(d)}`),Yt(r,s,n,t,i),{synced:0,superseded:c,warnings:t}}return l.errors?(Yt(r,s,n,t,i),t.push(...l.errors.map(d=>`sync facts: ${d.code}: ${d.detail}`)),{synced:0,superseded:c,warnings:t}):(l.warnings&&t.push(...l.warnings.map(d=>`sync facts: ${d}`)),{synced:s.length,superseded:c,warnings:t})}var Ge="pending-facts.ndjson",qe=".pending-facts.bad";function Yt(e,t,r,n,i){try{let o={by:r,ts:new Date().toISOString(),facts:t.map(c=>({...c,about_cid:c.about_cid??"",event_id:`exec-fact:${c.execution_id}:${c.ref}`}))},s=null;try{s=ee(e,{deadlineMs:i??5e3})}catch{n.push("sync facts: store lock busy \u2014 parking without it (a concurrent queue rewrite may race this line)")}try{Zt(T(e,Ge),JSON.stringify(o)+`
5
- `)}finally{s?.()}n.push(`sync facts: commit failed \u2014 ${t.length} fact(s) parked to ${T(e,Ge)}; they replay on the next sync`)}catch(o){n.push(`sync facts: could not park the failed batch (${o instanceof Error?o.message:String(o)}) \u2014 this run's facts are LOST`)}}function rn(e,t,r){let n=T(e,Ge);if(!O(n))return;let i;{let a=ee(e,{deadlineMs:r??5e3});try{i=P(n,"utf8")}finally{a()}}let o=i.split(`
6
- `).filter(a=>a.trim()!=="");if(o.length===0)return;let s=new Set,c=[],u=[];for(let a of o){let p=null;try{let d=JSON.parse(a);d&&Array.isArray(d.facts)&&(p=d)}catch{}if(!p){c.push(a),s.add(a);continue}let l=Wt(e,p);if(l.errors){if(l.errors.some(d=>d.code==="STALE_BASIS")){t.push(`sync: parked facts replay deferred (${l.errors[0].detail}) \u2014 retrying next sync`);continue}c.push(a),s.add(a),t.push(`sync: parked facts line quarantined to ${T(e,qe)} (${l.errors.map(d=>`${d.code}: ${d.detail}`).join("; ")})`);continue}for(let d of l.rejected){let f=p.facts.find(m=>m.event_id===d.event_id);u.push({parent:a,line:JSON.stringify({...f??{event_id:d.event_id},_reason:d.errors})})}l.rejected.length>0&&t.push(`sync: ${l.rejected.length} parked fact(s) quarantined to ${T(e,qe)} (${l.rejected.map(d=>d.errors.map(f=>`${f.code}: ${f.detail}`).join("; ")).join(" | ")})`),s.add(a),l.warnings&&t.push(...l.warnings.map(d=>`sync: ${d}`)),l.applied.length>0&&t.push(`sync: replayed ${l.applied.length} parked fact(s) from a previous run`)}if(s.size!==0)try{let a=ee(e,{deadlineMs:r??5e3});try{let l=(O(n)?P(n,"utf8"):"").split(`
7
- `).filter(g=>g.trim()!==""),d=[...c.filter(g=>l.includes(g)),...u.filter(g=>l.includes(g.parent)).map(g=>g.line)];d.length>0&&Zt(T(e,qe),d.map(g=>g+`
8
- `).join(""));let f=l.filter(g=>!s.has(g)),m=`${n}.tmp.${process.pid}`;tr(m,f.length>0?f.join(`
9
- `)+`
10
- `:""),er(m,n)}finally{a()}}catch(a){t.push(`sync: queue rewrite failed (${a instanceof Error?a.message:String(a)}) \u2014 already-applied lines dedupe next sync; bad lines re-quarantine then`)}}function nn(e,t){let r=[],n=new Set,i=o=>{if(n.has(o)||!O(o))return;n.add(o);let s;try{s=P(o,"utf8")}catch(c){t.push(`sync: unreadable unit ${o} (${c instanceof Error?c.message:String(c)}) \u2014 skipped`);return}for(let c of s.split(`
11
- `)){let u=/^@import\s+(\S+)\s*$/.exec(c.trim());if(!u)continue;let a=ae(u[1])?u[1]:ce(He(o),u[1]);if(!O(a))continue;let p;try{p=P(a,"utf8")}catch(l){t.push(`sync: unreadable import ${a} (${l instanceof Error?l.message:String(l)}) \u2014 skipped; importer continues`);continue}F(p)?.id&&i(a)}r.push({path:o})};return i(e),r}function Jt(e,t){let r=e.resolve(t),n=r?e.tipOf(r.cid):null;return!!(r&&n&&!e.superseded.has(n)&&e.nodeLabel.get(n)==="ac")}function on(e,t,r){let n=e.split(`
12
- `),i=ft(n);return n.map((o,s)=>{let c=mt.exec(o.trim());if(!c||i.has(s))return o;let u=c[1];if(r.resolve(u))return o;let a=ae(u)?u:ce(t,u);if(!O(a))return o;let p=F(P(a,"utf8"))?.id;return!p||!r.resolve(p)?o:`@import ${p}`}).join(`
13
- `)}function sn(e,t,r,n,i,o,s){let c=t.getNode(r);if(!c)return{oracleTier:!1,error:"tip unreadable"};let u=on(ht(n),o,t),a=String(c.content.test_md_blob??""),p=/^#\s+(.+?)\s*$/m.exec(u)?.[1]??String(c.content.title??""),l={...c.content,test_md_blob:u,definitionId:i,title:p};{let h=an(u);h.target!==void 0?l.target=h.target:delete l.target,h.app!==void 0?l.app=h.app:delete l.app}let d=vt("test",l);if(d.length>0)return{oracleTier:!1,error:d.map(h=>h.detail).join("; ")};let f=yt("test",l);if(f===r)return{newCid:r,oracleTier:!1};let m=Xt(a)!==Xt(u);if(bt(t,r,f))return{oracleTier:m,error:"file content reproduces an already-superseded version (supersession cycle guard) \u2014 graph kept; re-edit forward or redesign"};let g=wt({graph:t,oldTip:r,newCid:f,newLabel:"test",by:s,reason:`re-blessed onto ${f} (edited on disk, run sync)`});if(g.errors.length>0)return{oracleTier:m,error:`edge re-bless refused: ${g.errors.join("; ")}`};let w=te(e);if(t.latestHash!==w)return{oracleTier:m,error:`store advanced under the sync (basis ${String(t.latestHash)} vs head ${String(w)}) \u2014 re-run to retry`};try{H(e,{ts:new Date().toISOString(),proposal_id:null,nodes:[{cid:f,label:"test",content:l}],edges:g.edges,review:[{id:f,kind:"review-item",resolution:"edited",edit:null,reason:"edited on disk (run sync)",by:s}],supersessions:[{kind:"node",old:r,new:f,reason:"edited on disk (run sync)",by:s},...g.supersessions],source_head_moves:{}},{expectPrev:w})}catch(h){return{oracleTier:m,error:h instanceof Error?h.message:String(h)}}return G(e),{newCid:f,oracleTier:m}}function an(e){let t=pt(e);return{...typeof t.target=="string"?{target:t.target}:{},...typeof t.app=="string"?{app:t.app}:{}}}function Xt(e){let t=[],r=e.split(`
14
- `),n=r.some(o=>/^##\s/.test(o)&&_e.test(o)),i=!1;for(let o of r){if(/^##\s/.test(o)){let s=_e.exec(o);i=n?s!==null:/\bassert\b/i.test(o),s&&t.push(`v:${s[1].trim()}`);continue}i&&o.trim()!==""&&t.push(o.trim())}return t.join(`
15
- `)}var cn=0;function Qt(e,t,r,n){try{let i=t.split(`
16
- `),o=-1;if(i[0]?.trim()==="---"){for(let u=1;u<i.length;u++)if(i[u].trim()==="---"){o=u;break}}if(o<0)return;let s=_t(i,o);if(!s)return;if(s.baseLine!==void 0){let u=i[s.baseLine].endsWith("\r")?"\r":"";i[s.baseLine]=`${s.childIndent}base: ${r}${s.baseComment?` ${s.baseComment}`:""}${u}`}else if(s.strayBase){n.push(`sync: ${e} has a base: line this scanner cannot confidently rewrite (unexpected indentation or key quoting) \u2014 pin refresh skipped (stale pin until the shape is fixed)`);return}else{let a=i[s.idLine??s.start].endsWith("\r")?"\r":"";i.splice((s.idLine??s.start)+1,0,`${s.childIndent??" "}base: ${r}${a}`)}let c=`${e}.tmp-sync.${process.pid}-${cn++}`;tr(c,i.join(`
17
- `)),er(c,e)}catch(i){n.push(`sync: pin refresh failed for ${e} (${i instanceof Error?i.message:String(i)}) \u2014 next run self-heals`)}}var gn={passed:"passed",failed:"failed",broken:"blocked",skipped:"not-run"},ir=(e,t)=>{try{if(!Ke(t))return{status:"skipped",reason:"no context store at the project root"};let r=M(e,"tests");if(!Ke(r))return{status:"skipped",reason:"pack has no tests/"};let n=new Map;for(let c of un(r)){let u=M(r,c,"result.yaml");if(!Ke(u)||!mn(M(r,c)).isDirectory())continue;let a=$(ln(u,"utf8"));if(!a?.definition_id&&!a?.assurance_id)continue;let p=rr(a.steps??[]),l={testShortId:String(a.test??c),execution:gn[String(a.status)]??"not-run",...p.length?{acs:p}:{}};a.assurance_id&&n.set(`id:${a.assurance_id}`,l),a.definition_id&&n.set(`def:${a.definition_id}`,l)}let i=xt(x(t),n,{scope:"run"}),o=kt(i);qt(e,t,i);let s=k({...i,rollup:o},{lineWidth:-1});return dn(M(e,"coverage"),{recursive:!0}),fn(M(e,"coverage","usecases.yaml"),s),{status:"written"}}catch(r){try{pn(M(e,"coverage","sources"),{recursive:!0,force:!0})}catch{}return{status:"skipped",reason:r instanceof Error?r.message:String(r)}}};async function hn(e){try{let t=new W({origin:"inline",runKind:"author",pid:e.pid,title:e.title,started:new Date().toISOString(),producerVersion:e.producerVersion,surfaces:e.surfaces,objectiveOrName:e.objectiveOrName,sessionId:e.sessionId,cwd:e.cwd,packRootDir:e.packRootDir}),r=await t.start();return{session:t,...r,packDir:t.pack,spawns:[],startedAtMs:Date.now(),cwd:e.cwd}}catch(t){return console.warn("evidence: inline pack creation failed",t),null}}function vn(e,t,r){if(!e)return;e.session.noteSpawn(t),t.resolution&&(e.resolution=t.resolution),e.runnerEnvironment=st(e.runnerEnvironment,t.runnerEnvironment);let n=(r?.per_flow_metadata??[]).map(i=>({resultCode:i?.result_code!=null?Number(i.result_code):null}));e.spawns.push({resultCode:r?.result_code!=null?Number(r.result_code):null,...n.length?{perFlow:n}:{}})}function yn(e){if(e)return{packTestDir:e.packTestDir,ordinalOffset:e.session.nextOrdinalOffset()}}async function bn(e,t){if(!e)return null;if(e.finalized)return e.finalized;let r=(n,i,o)=>t.log?t.log("warn",n,i,o):console.warn(`evidence: ${i}`,o??"");try{if(t.recordedTestPath)try{await e.session.writeDefinition(await _n.readFile(t.recordedTestPath,"utf8"))}catch(s){r("EVIDENCE_DEFINITION_FAILED","could not attach synthesized test.md",{error:String(s)})}let n=t.cdpBrowserCapture?await t.cdpBrowserCapture():void 0,i=await e.session.writeResult({steps:e.session.steps,spawns:e.spawns.length?e.spawns:[{resultCode:null}],externalIdInput:{...t.externalIdInput,execution_id:e.executionId},runnerEnv:Ue({cdpBrowser:n,resolution:e.resolution,runnerEnvironment:e.runnerEnvironment,deviceName:t.deviceName,deviceModel:t.deviceModel,pixelResolution:await Tt(e.packTestDir)}),intentEnv:ct(t.model,e.runnerEnvironment),durationMs:t.durationMs??Date.now()-e.startedAtMs,log:t.log});try{if(t.recordedTestPath){let s=nr({cwd:t.cwd??e.cwd??process.cwd(),members:[{path:t.recordedTestPath,verdict:i,executionId:e.executionId,startedAt:new Date(e.startedAtMs).toISOString(),mode:"inline",local:t.local??!1}]});for(let c of s.warnings)r("EXEC_SYNC",c)}}catch(s){r("EXEC_SYNC","exec-sync failed",{error:String(s)})}try{let s=(t.coverageWriter??ir)(e.packDir,re(t.cwd??e.cwd??process.cwd()));s.status==="skipped"&&r("EVIDENCE_COVERAGE_SKIPPED",`coverage/usecases.yaml not written: ${s.reason}`)}catch(s){r("EVIDENCE_COVERAGE_SKIPPED","coverage writer threw",{error:String(s)})}let o=await ze({executionId:e.executionId,testId:e.testId,saved:t.saved,runKind:"author",verdict:i,cwd:t.cwd??e.cwd,packDir:e.packDir,tuiLogPath:t.tuiLogPath,log:t.log,surface:"inline",requireRealLog:!!e.runnerEnvironment?.native_platform,appiumMarks:e.session.appiumMarks});return e.finalized=o,t.log?.("info","EVIDENCE_SEALED","Inline pack sealed",{execution_id:e.executionId,verdict:i,valid:o.valid,pack:e.packDir,store_copy:o.storePath??null}),o}catch(n){return r("EVIDENCE_SEAL_FAILED","inline pack finalize failed",{error:String(n)}),null}}import{statSync as wn,openSync as kn,readSync as xn,closeSync as En}from"fs";import{basename as In,resolve as Sn}from"path";async function Rn(e,t,r={}){let n=r.out??(p=>process.stdout.write(p+`
18
- `)),i=p=>(n(`error: ${p}`),2);if(t.env!=="prod"&&t.env!=="stage")return i(`invalid --env: ${String(t.env)}`);if(t.port!==void 0&&(!Number.isInteger(t.port)||t.port<1||t.port>65535))return i("invalid --port: expected an integer 1-65535");let o;try{o=K(t.env,t.viewerUrl),new URL(o)}catch{return i(`invalid --viewer-url: ${t.viewerUrl}`)}if(e.length===0)return i("no pack paths given");let s=new Map;for(let p of e){let l=Sn(p),d;try{d=wn(l)}catch{return i(`${p}: not found`)}if(d.isDirectory())return i(`${p}: is a directory \u2014 packs must be sealed .evidence files (run the execution to completion, or seal it, first)`);if(!d.isFile())return i(`${p}: not a regular file`);let f=Buffer.alloc(2),m=kn(l,"r");try{xn(m,f,0,2,0)}finally{En(m)}if(f.toString("latin1")!=="PK")return i(`${p}: not a sealed evidence pack (zip magic missing)`);let g=In(l);if(s.has(g))return i(`duplicate pack basename: ${g} (URL names collide \u2014 rename one)`);s.set(g,l)}let c=r.log??((p,l,d)=>process.stderr.write(`warn: ${l} reason=${d.reason} path=${d.path}
19
- `)),u;try{u=await ve({packs:s,allowedOrigins:[new URL(o).origin],port:t.port,log:c})}catch(p){return i(`could not bind 127.0.0.1${t.port?`:${t.port}`:""} \u2014 ${p.message}`)}n(`serving ${s.size} pack${s.size===1?"":"s"} on http://127.0.0.1:${u.port}`);for(let p of s.keys()){let l=u.urlFor(p);n(p),n(` pack ${l}`),n(` viewer ${ye(l,o)}`)}return n("press Ctrl-C to stop"),await(r.hold??An)(),await u.close(),0}function An(){return new Promise(e=>{let t=process.listeners("SIGINT");process.removeAllListeners("SIGINT"),process.once("SIGINT",()=>{for(let r of t)process.on("SIGINT",r);e()})})}import{promises as de}from"fs";import{tmpdir as Fn}from"os";import{join as ar,resolve as Ye}from"path";var Pn=["error","prefer_first","prefer_latest","discard"],$n=["external_id.commit_id","external_id.test_id","environment.os","environment.os_version","environment.browser","environment.browser_version"];function or(e){let t=e.replace(/-/g,"_");return Pn.includes(t)?t:null}function sr(e){let t=e==="discard"?{on_collision:"discard"}:{on_collision:"error",identity:{keys:[...$n],on_same:e??"nest",on_different:e?"error":"split"}};return k({packs:{require_status:"finalized",require_valid:"L1",on_ineligible:"abort"},tests:t,rules:[{file:"run.yaml",key:"run_id",must:"different",on_violation:"skip"},{file:"result.yaml",key:"external_id.project_id",must:"same",on_violation:"error"},{file:"result.yaml",key:"external_id.org_id",must:"same",on_violation:"error"}]},{lineWidth:-1})}async function We(e){try{if(!e.isTTY){e.log(be(e.packPath));return}let t=K(e.env);await(e.renderPrompt??Ln)(e.packPath,t)}catch(t){try{e.log(`evidence view failed \u2014 ${t.message}`)}catch{}}}async function Ln(e,t){let r=await import("./react-QWOAB3TB.js"),{render:n}=await import("./build-JIKYOZUH.js"),{EvidenceViewOffer:i}=await import("./EvidenceViewOffer-AZRAILJQ.js");await new Promise(o=>{let s=n(r.default.createElement(i,{packPath:e,viewerBase:t,onDone:()=>{s.unmount(),o()}}),{stdout:process.stderr,exitOnCtrlC:!1})})}async function Cn(e,t,r=process.cwd(),n={}){let i=n.out??(d=>process.stdout.write(d+`
20
- `)),o=n.err??(d=>process.stderr.write(d+`
21
- `)),s=d=>(o(`evidence merge: ${d}`),2);if(!t.runId)return s("--run-id is required (merged identity is the caller's fact)");if(t.rules&&t.onCollision)return s("--rules and --on-collision are mutually exclusive");let c;if(t.onCollision!==void 0){let d=or(t.onCollision);if(!d)return s(`invalid --on-collision: ${t.onCollision} (expected error | prefer-first | prefer-latest | discard)`);c=d}let u=[];for(let d of e){let f=await Dn(d,r);if(!f)return s(`no pack found for "${d}"`);u.push(f)}let a=t.out?Ye(r,t.out):y(t.runId,r),p=null,l;t.rules?l=Ye(r,t.rules):(p=await de.mkdtemp(ar(Fn(),"kane-merge-rules-")),l=ar(p,"merge-rules.yaml"),await de.writeFile(l,sr(c)));try{let d=await(n.mergeFn??dt)(u,{runId:t.runId,out:a,rulesPath:l,title:t.title,finalize:t.finalize});return t.json?i(JSON.stringify(d)):jn(i,d),d.output.finalized&&!t.json&&await(n.offer??We)({packPath:a,env:t.env,isTTY:n.isTTY??(!!process.stdin.isTTY&&!!process.stderr.isTTY),log:o}),0}catch(d){let f=d instanceof Error?d.message:String(d);return d?.code==="ABORT"?(o(`evidence merge: aborted \u2014 ${f}`),1):s(f)}finally{p&&await de.rm(p,{recursive:!0,force:!0}).catch(()=>{})}}async function Dn(e,t){let r=Ye(t,e);if(await cr(r))return r;let n=y(e,t);return await cr(n)?n:null}async function cr(e){try{return await de.stat(e),!0}catch{return!1}}function jn(e,t){let{packs:r,tests:n,output:i}=t;e(`evidence: merged ${n.merged} tests from ${r.eligible.length} packs -> ${i.path} (${i.finalized?"sealed":"live"})`);for(let o of r.skipped)e(` skipped ${o.runId}: ${o.rule} \u2014 ${o.reason}`);for(let o of n.collisions){let s;o.action==="nest"?s=`nested into ${o.folder}, latest ${o.winner}`:o.action==="split"?s=`split into ${o.folder}`:s=`winner ${o.winner}`,e(` collision ${o.test}: ${s} (${o.rule})`)}for(let o of n.discarded)e(` discarded ${o}`)}import{copyFileSync as On,existsSync as Je,mkdirSync as Tn}from"fs";import{join as dr}from"path";function Mn(e,t,r){try{let n=dr(e,"auteur","execution.json");if(Je(n))return!0;for(let i of t)if(!(!i||!Je(i)))return Tn(dr(e,"auteur"),{recursive:!0}),On(i,n),!0}catch(n){try{r?.("debug","EVIDENCE_BLOB_COPY_FAILED","auteur execution blob copy failed",{operation:"ensureAuteurExecution",source:t.find(i=>i&&Je(i))??null,error:n instanceof Error?n.message:String(n)})}catch{}}return!1}import{readFileSync as Nn}from"fs";import{join as Bn}from"path";var ur="module_block";var Vn=new Set(["generative_block",ur]);function Qe(e){let t=[],r=!0,n=o=>{if(o===null||typeof o!="object")return;let s=o;if(Array.isArray(s.operations))for(let c of s.operations){let u=c?.operation_id;typeof u=="string"&&u&&t.push(u)}if(Array.isArray(s.children)){Vn.has(s.content_type)||(r=!1);for(let c of s.children)n(c)}if(Array.isArray(s.branches)){r=!1;for(let c of s.branches){let u=c?.children;if(Array.isArray(u))for(let a of u)n(a)}}},i=e?.instructions;if(Array.isArray(i))for(let o of i)n(o);return{ids:t,linear:r}}function zn(e){return Qe(e).ids}function Xe(e,t){let r=new Set(t.map(c=>c.action_id).filter(Boolean)),n=-1;for(let c of r){let u=e.indexOf(c);u>n&&(n=u)}let i=t.reduce((c,u)=>Math.max(c,u.ordinal),0),o=new Set,s=[];for(let c of e.slice(n+1))r.has(c)||o.has(c)||(o.add(c),s.push({id:c,ordinal:++i,status:"skipped",action_id:c}));return s}function lr(e,t){let r=new Set(t),n=e.filter(o=>o.action_id);if(n.some(o=>r.has(o.action_id))||n.length>t.length)return null;let i=0;return e.map(o=>o.action_id?{...o,action_id:t[i++]}:o)}function Un(e,t){if(e.length>t.length)return!1;for(let r=0;r<e.length;r++)if(t[r]!==e[r].action_id)return!1;return!0}function qn(e,t,r,n=!0){if(t.length===0)return{steps:e,tail:[]};let i=(r&&n?lr(e,t):null)??e,o=i.filter(c=>c.action_id),s=new Set(t);return o.length>0&&o.every(c=>s.has(c.action_id))?{steps:i,tail:Xe(t,i)}:o.length>0&&!Un(o,t)?{steps:i,tail:[],unjoined:!0}:{steps:i,tail:Xe(t,i)}}function pr(e){try{let t=Nn(Bn(e,"auteur","execution.json"),"utf8");return Qe(JSON.parse(t))}catch{return{ids:[],linear:!0}}}function Hn(e){return pr(e).ids}export{D as a,we as b,ke as c,xe as d,Ee as e,Ie as f,It as g,Re as h,_r as i,Ae as j,Pe as k,hr as l,vr as m,$e as n,ne as o,Ce as p,De as q,je as r,Oe as s,yr as t,br as u,Te as v,wr as w,Me as x,Ne as y,Be as z,Ct as A,ze as B,Tt as C,Ue as D,Bt as E,Br as F,W as G,Kr as H,rr as I,nr as J,ir as K,hn as L,vn as M,yn as N,bn as O,Rn as P,sr as Q,We as R,Cn as S,Mn as T,ur as U,Qe as V,zn as W,Xe as X,lr as Y,qn as Z,pr as _,Hn as $};
@@ -1,3 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as Ee}from"./chunk-KGKJU27A.js";import{a as he,b as _e,d as be,e as Se}from"./chunk-BB2W35TW.js";import{a as me}from"./chunk-DNNZ353O.js";import{B as le,c as fe,h as ue,o as pe}from"./chunk-W3Z7AZNT.js";import{a as ge}from"./chunk-JQW2QFSX.js";import{a as ce,b as K}from"./chunk-UH2ZTX4E.js";import{g as de,j as ae}from"./chunk-XMTSHHYQ.js";import{d as u,e as p,f as ie,g as oe,h as re}from"./chunk-AKX4VRRR.js";var Ce=/\s@verifies\s+(ac-[\w.:\/-]+(?:\s*,\s*ac-[\w.:\/-]+)*)\s*$/,N=r=>({record:null,errors:r,minted:{},logicalIds:{},superseded:[],warnings:[],finalizedTests:{}});function w(r){return r.toLowerCase().trim().replace(/\s+/g," ")}function ke(r,I){let t=r.resolve(I);if(!t||r.nodeLabel.get(t.cid)!==u.USECASE||t.superseded)return[];let m=new Set;for(let{cid:g}of r.byLabel(u.SCENARIO))if(!r.superseded.has(g)&&r.edgesFrom(g).some(O=>O.type===p.BELONGS_TO&&r.tipOf(O.dst)===t.cid)){m.add(g);for(let O of r.edgesInto(g))O.type!==p.AUTOMATES||r.superseded.has(O.src)||m.add(O.src)}return[...m]}function Be(r){let{contextDir:I,graph:t,sections:m,by:g}=r,O=r.engine??"design@1",J=de(I);if(t.latestHash!==J)return N([{code:"STALE_BASIS",detail:`graph opened at ${String(t.latestHash)} but chain head is ${String(J)} \u2014 re-open and retry`}]);let D=t.resolve(r.ucRef);if(!D||t.nodeLabel.get(D.cid)!==u.USECASE||D.superseded)return N([{code:"UNKNOWN_UC",detail:`${r.ucRef} is not a live use-case`}]);let S=D.cid,_=[],W=/^design@(\d+)$/.exec(r.templateVersion??""),$e=W!==null&&Number.parseInt(W[1],10)>=3,Q=new Map,ye=(e,s)=>{let n=Q.get(e.source_cid);if(n===void 0){let c=me(r.contextDir,t,e.source_cid);n=c?Ee(c.toString("utf8")):null,Q.set(e.source_cid,n)}if(n===null)return _.push({code:"CITE_UNVERIFIED",detail:`${s}: source ${e.source_id} (${e.source_cid.slice(0,19)}) has no citable text to verify against`}),!1;let d=fe(t.mediaOf(e.source_cid),e,n);if(d.length>0){for(let c of d)_.push({code:"CITE_UNVERIFIED",detail:`${s}: ${c.code}: ${c.detail}`});return!1}return!0},T=[],L=[],y=[],G=[],F=[],E={},x={},j={},k=[],P=[],X=new Set,M=[],q=new Set,R=new Set,V=[];{let e=r.forceScope??(r.force?ke(t,r.ucRef):[]),s=new Set;r.sections.scenarios?.length&&s.add(u.SCENARIO),r.sections.tests?.length&&s.add(u.TEST);for(let n of e)t.superseded.has(n)||(s.has(t.nodeLabel.get(n)??"")?R.add(n):V.push(n))}let A=new Set,z=e=>!t.superseded.has(e)&&(!R.has(e)||A.has(e)),v=(e,s,n)=>{if(E[e])return E[e];let d=t.resolve(e),c=d?z(d.cid)?d.cid:t.tipOf(d.cid):null;return!d||!c||!z(c)?(_.push({code:"UNKNOWN_REF",detail:`${s}: '${e}' is neither in this payload nor a live committed node`}),null):n&&t.nodeLabel.get(c)!==n?(_.push({code:"ILLEGAL_EDGE",detail:`${s}: '${e}' is a ${t.nodeLabel.get(c)}, expected ${n}`}),null):c},ve=(e,s,n,d)=>{if(t.nameOf.has(s)){x[d]=t.nameOf.get(s);return}let c=le(e,h=>X.has(h),t.names.keys());c!==null&&(X.add(c),G.push({cid:s,slug:c,by:g}),x[d]=c)},B=(e,s,n,d)=>{for(let h of ie(e,n))_.push({code:h.code,detail:`${s}: ${h.detail}`});let c=ce(e,n);return t.hasNode(c)&&!t.superseded.has(c)?(R.has(c)&&A.add(c),E[s]=c,c):(T.push({cid:c,label:e,content:n}),E[s]=c,ve(e,c,d,s),c)},$=(e,s,n,d,c)=>{let h=K(e,s,n,d);if(t.edgesFrom(s).some(i=>i.ecid===h&&!t.superseded.has(i.ecid))){e===p.AUTOMATES&&q.add(n);return}if(t.superseded.has(h)){_.push({code:"EDGE_RETRACTED",detail:`${c}: this ${e} edge was retracted (${h}) \u2014 retraction is terminal for commits. Add a NEW relationship (different endpoint or props), redesign, or revert the retracting record`});return}let C=t.nodeLabel.get(s)??T.find(i=>i.cid===s)?.label??"(unknown)",U=t.nodeLabel.get(n)??T.find(i=>i.cid===n)?.label??"(unknown)";for(let i of re(e,C,U,d))_.push({code:i.code,detail:`${c}: ${i.detail}`});let a=ue(t,e,s,n,M);if(a){_.push({code:a.code,detail:`${c}: ${a.detail}`});return}if(e===p.BELONGS_TO||e===p.SCOPED_TO){let i=ge(t,{type:e,src:s,dst:n},{pending:M,retracted:new Set(y.flatMap(o=>o.kind==="edge"?[o.ecid]:[])),freed:new Set([...R].filter(o=>!A.has(o)))},c);if(i){_.push(i);return}}if(e===p.AUTOMATES){if(q.has(n)){_.push({code:"CARDINALITY_VIOLATION",detail:`${c}: two automates onto ${n} in one record (strict 1:1)`});return}if(q.add(n),!R.has(n)||A.has(n)){let i=l=>R.has(l)&&!A.has(l);if(t.edgesFrom(s).some(l=>l.type===p.AUTOMATES&&l.dst!==n&&!t.superseded.has(l.dst)&&!i(l.dst))&&t.hasNode(s)){_.push({code:"CARDINALITY_VIOLATION",detail:`${c}: automates from ${s} already has a live edge \u2014 supersede it first`});return}if(t.edgesInto(n).some(l=>l.type===p.AUTOMATES&&l.src!==s&&!t.superseded.has(l.src)&&!i(l.src))){_.push({code:"CARDINALITY_VIOLATION",detail:`${c}: automates onto ${n} already has a live edge \u2014 strict 1:1, supersede it first`});return}}}L.push({ecid:K(e,s,n,d),type:e,src:s,dst:n,props:d}),M.push({src:s,dst:n,type:e})},H=new Set;for(let e of m.gaps??[]){let s=e.temp_ref??e.ref??"gap",n=e.question;if(!n||typeof n!="object"||!n.header||!Array.isArray(n.options)||n.options.length===0||!Number.isInteger(n.recommended_index)){_.push({code:"GAP_QUESTION_INCOMPLETE",detail:`${s}: design gaps carry a full ranked question object (header/options/recommended_index)`});continue}e.kind==="budget-evicted"&&e.ref&&H.add(e.ref);let d={kind:e.kind,question:n,derived:!0,uc:S,...e.risk?{risk:e.risk}:{},...e.risk_rationale?{risk_rationale:e.risk_rationale}:{},...e.text?{text:e.text}:{},...e.ref?{ref:e.ref}:{}};B(u.GAP,s,d,String(n.header))}let Z=new Map;for(let{cid:e,content:s}of t.byLabel(u.SCENARIO))z(e)&&t.edgesFrom(e).some(n=>n.type===p.BELONGS_TO&&t.tipOf(n.dst)===S)&&Z.set(w(String(s.title??"")),e);for(let e of m.scenarios??[]){let s=Z.get(w(e.title));if(s){_.push({code:"DUPLICATE_SCENARIO",detail:`${e.temp_ref}: '${e.title}' duplicates live scenario ${t.nameOf.get(s)??s} \u2014 exercise/link it instead (reuse before minting)`});continue}let n={title:e.title,intent:e.intent,case_type:e.case_type,derived:!0,...e.technique_notes?{technique_notes:e.technique_notes}:{},...e.description?{description:e.description}:{},...e.parameters?{parameters:e.parameters}:{},...e.tags?{tags:e.tags}:{}};B(u.SCENARIO,e.temp_ref,n,e.title)}for(let e of m.scenarios??[]){let s=E[e.temp_ref];if(s){$(p.BELONGS_TO,s,S,{},e.temp_ref);for(let n of e.depends_on??[]){let d=v(n,`${e.temp_ref}.depends_on`,u.SCENARIO);d&&$(p.DEPENDS_ON,s,d,{},`${e.temp_ref}.depends_on`)}}}for(let e of m.acs??[]){let s={text:e.text,kind:e.kind,risk:e.risk,derived:!0,...e.expected_answer?{expected_answer:e.expected_answer}:{},...e.measurable!==void 0?{measurable:e.measurable}:{}},n=B(u.AC,e.temp_ref,s,e.text);if(!n)continue;let d=e.scope?.type==="scenario"&&e.scope.ref?v(e.scope.ref,`${e.temp_ref}.scope`,u.SCENARIO):S;d&&!t.edgesFrom(n).some(c=>c.type===p.SCOPED_TO&&!t.superseded.has(c.ecid))&&$(p.SCOPED_TO,n,d,{},`${e.temp_ref}.scope`);for(let c of e.cites??[]){if($e&&!ye(c,`${e.temp_ref}.cite`))continue;let h={source_id:c.source_id,source_cid:c.source_cid,anchor:c.anchor,...c.quote?{quote:c.quote}:{}};$(p.DERIVES,c.source_cid,n,h,`${e.temp_ref}.cite`)}}for(let e of m.exercises??[]){let s=v(e.scenario,"exercises.scenario",u.SCENARIO),n=v(e.ac,"exercises.ac",u.AC);s&&n&&$(p.EXERCISES,s,n,{},`exercises ${e.scenario}\u2192${e.ac}`)}let ee=0;for(let e of m.scoped_to_repoints??[]){let s=v(e.ac,"scoped_to_repoints.ac",u.AC),n=v(e.to,"scoped_to_repoints.to");if(!s||!n)continue;let d=t.edgesFrom(s).find(c=>c.type===p.SCOPED_TO&&!t.superseded.has(c.ecid));if(d&&d.dst===n){ee+=1,k.push(`scoped_to_repoints ${e.ac}: already scoped to ${e.to} \u2014 no-op`);continue}d&&y.push({kind:"edge",ecid:d.ecid,reason:`re-scoped to ${e.to} by ${g.id}`,by:g}),$(p.SCOPED_TO,s,n,{},`scoped_to_repoints ${e.ac}`)}let te=new Map;if(r.finalizeTestBody)for(let[e,s]of t.nameOf)te.set(t.tipOf(e),s);let ne=e=>t.nameOf.get(e)??te.get(t.tipOf(e))??null,Oe=e=>{let s=E[e];if(s)return x[e]??ne(s);if(t.names.has(e))return t.resolve(e)?e:null;let n=t.resolve(e);return n?ne(t.tipOf(n.cid)):null};for(let e of m.tests??[]){for(let a of e.reuses??[])H.has(a)&&_.push({code:"REUSES_EVICTED",detail:`${e.temp_ref}: reuses '${a}' which was budget-evicted \u2014 drop the edge; the dependent gap names the missing @import`});{let a=o=>o==="emulator"||o==="simulator"?o:"web",i=o=>{let f=(m.tests??[]).find(Te=>Te.temp_ref===o);if(f)return a(f.target);let l=t.resolve(o),b=l?t.getNode(t.tipOf(l.cid)??l.cid)?.content:void 0;if(typeof b?.target=="string")return a(String(b.target));let se=/^\s*\[mobile:\s*(emulator|simulator)\]/m.exec(String(b?.test_md_blob??""));return se?se[1]:"web"};for(let o of e.reuses??[]){let f=a(e.target),l=i(o);f!==l&&_.push({code:"REUSES_CROSS_SURFACE",detail:`${e.temp_ref}: reuses '${o}' which runs on ${l} while this test runs on ${f} \u2014 a test imports only same-surface units`})}}let s=e.test_md_blob,n=e.definitionId,d=e.objectives_blob;if(r.finalizeTestBody){let a;try{a=r.finalizeTestBody({temp_ref:e.temp_ref,test_md_blob:e.test_md_blob,verifies:e.verifies,reuses:e.reuses??[]},Oe)}catch(i){return N([{code:"FINALIZE_BODY",detail:`${e.temp_ref}: ${i instanceof Error?i.message:String(i)}`}])}a&&(s=a.test_md_blob,n=a.definitionId,d=a.objectives_blob??d,j[e.temp_ref]=n)}let c={title:e.title,check:e.check,definitionId:n,derived:!0,...e.config?{config:e.config}:{},...s?{test_md_blob:s}:{},...d?{objectives_blob:d}:{},...e.surface_required!==void 0?{surface_required:e.surface_required}:{},...e.target?{target:e.target}:{},...e.app&&e.target?{app:e.app}:{}},h=B(u.TEST,e.temp_ref,c,e.title);if(!h)continue;let C=v(e.automates,`${e.temp_ref}.automates`,u.SCENARIO);C&&$(p.AUTOMATES,h,C,{},`${e.temp_ref}.automates`);for(let a of e.verifies){let i=v(a,`${e.temp_ref}.verifies`,u.AC);i&&$(p.VERIFIES,h,i,{},`${e.temp_ref}.verifies`)}for(let a of e.reuses??[]){if(H.has(a))continue;let i=v(a,`${e.temp_ref}.reuses`,u.TEST);i&&$(p.REUSES,h,i,{},`${e.temp_ref}.reuses`)}for(let a of e.verifies){let i=E[a]??t.resolve(a)?.cid;i&&(t.trust.get(i)??"derived")==="derived"&&!T.some(o=>o.cid===i)?k.push(`${e.temp_ref}: verifies ${a} which is still DERIVED (unapproved) \u2014 committed anyway; approve it in chat or via review`):i&&E[a]===i&&(m.acs??[]).some(o=>o.temp_ref===a)&&k.push(`${e.temp_ref}: verifies ${a} minted in this same record (unapproved) \u2014 committed anyway; approve it in chat`)}if(!String(e.test_md_blob??"").split(`
3
- `).some(a=>/^##\s/.test(a)&&!/—\s?assert/.test(a)&&Ce.test(a))&&e.verifies.length>1){let a=e.check?.verified_against;k.push(`${e.temp_ref}: verifies ${e.verifies.length} ACs but machine-asserts only 1 (check.verified_against=${a!=null?String(a):"?"}) \u2014 the rest ride prose only`)}}let Y=[];{let e=(i,o)=>`${i??""}\0${w(String(o??""))}`,s=(i,o)=>r.reason?`${r.reason} \u2014 evolve by ${g.id}${o?` (${o})`:""}`:i,n=new Map;for(let i of T){if(i.label!==u.SCENARIO&&i.label!==u.TEST)continue;let o=e(i.label,i.content.title);n.set(o,[...n.get(o)??[],i.cid])}let d=new Map;for(let i of R){if(A.has(i))continue;let o=e(t.nodeLabel.get(i),t.getNode(i)?.content.title);d.set(o,[...d.get(o)??[],i])}for(let[i,o]of d){let f=n.get(i)??[],l=o.length===1&&f.length===1;for(let b of o)l?(y.push({kind:"node",old:b,new:f[0],reason:s(`--force redesign of ${r.ucRef} by ${g.id} (title-matched successor)`,"title-matched successor"),by:g}),Y.push({old:b,next:f[0]})):y.push({kind:"node",old:b,new:null,reason:s(`--force redesign of ${r.ucRef} by ${g.id}`),by:g}),P.push(b)}let c=i=>t.edgesFrom(i).some(o=>o.type!==p.SCOPED_TO?!1:o.dst===S||t.tipOf(o.dst)===S?!0:t.nodeLabel.get(o.dst)===u.SCENARIO&&t.edgesFrom(o.dst).some(f=>f.type===p.BELONGS_TO&&t.tipOf(f.dst)===S)),h=new Map;for(let{cid:i,content:o}of t.byLabel(u.AC)){if(t.superseded.has(i)||!c(i))continue;let f=w(String(o.text??""));h.set(f,[...h.get(f)??[],i])}let C=new Map;for(let i of T){if(i.label!==u.AC)continue;let o=w(String(i.content.text??""));C.set(o,[...C.get(o)??[],i.cid])}for(let[i,o]of h){let f=C.get(i)??[];o.length!==1||f.length!==1||(y.push({kind:"node",old:o[0],new:f[0],reason:s(`AC re-emitted with changed content by ${g.id} (text-matched successor)`,"AC text-matched successor"),by:g}),Y.push({old:o[0],next:f[0]}),P.push(o[0]))}let U=new Set(P),a=new Set;for(let i of y)i.kind==="edge"&&a.add(i.ecid);for(let{old:i,next:o}of Y)for(let f of t.edgesInto(i))oe(f.type)?.pin?.comparesTo!=="dst_tip"||t.superseded.has(f.src)||U.has(f.src)||a.has(f.ecid)||(y.push({kind:"edge",ecid:f.ecid,reason:`re-blessed onto ${o} (redirect successor of ${i}) by ${g.id}`,by:g}),a.add(f.ecid),L.some(b=>b.type===f.type&&b.src===f.src&&b.dst===o)||t.edgesFrom(f.src).some(b=>b.type===f.type&&b.dst===o))||f.type===p.AUTOMATES&&q.has(o)||$(f.type,f.src,o,f.props,`rebless ${f.type} from ${t.nameOf.get(f.src)??f.src}`)}if(_.length>0)return N(_);if(T.length===0&&L.length===0&&y.length===0&&F.length===0)return Object.keys(E).length>0||ee>0?(k.push("everything in this phase is already current \u2014 nothing re-committed"),{record:null,errors:null,minted:E,logicalIds:x,superseded:[],warnings:k,finalizedTests:j,...r.force||r.forceScope?{forceScopeRemaining:V}:{}}):N([{code:"EMPTY_DESIGN",detail:"finalize_design produced nothing to commit"}]);if(r.generationTicket){let e=be(t,r.generationTicket);if(e!==null)return N([e])}return{record:ae(I,{ts:new Date().toISOString(),proposal_id:null,nodes:T,edges:L,review:[],supersessions:y,source_head_moves:{},...G.length>0?{names:G}:{},...(()=>{for(let e of m.judgements??[]){let s=e.target?E[e.target]??t.resolve(e.target)?.cid??S:S;F.push({about:s,rationale:`[${e.kind}] ${e.rationale}`,by:g})}return F.length>0?{judgements:F}:{}})(),design_of:{uc_cid:S,engine:O},...r.generationTicket?{design_generation:Se(r.generationTicket,S,g)}:{},...r.eventIds&&r.eventIds.length>0?{event_ids:r.eventIds}:r.sid?{event_ids:pe(t,r.sid,"design",1)}:{},...r.sid?{sid:r.sid}:{},...r.phase?{design_phase:{uc_root:he(t,S),generation:r.generationTicket?.next_gen??_e(t,r.ucRef)?.gen??1,phase:r.phase,completeness:r.phaseCompleteness??"complete"}}:{}},{expectPrev:t.latestHash}).record,errors:null,minted:E,logicalIds:x,superseded:P,warnings:k,finalizedTests:j,...r.force||r.forceScope?{forceScopeRemaining:V}:{}}}function Ue(r,I){let t=[];for(let m of r){let g=m.design_phase;!g||typeof g!="object"||g.uc_root===I&&(typeof g.phase!="string"||typeof g.generation!="number"||t.push({phase:g.phase,generation:g.generation,seq:m.seq,completeness:g.completeness==="partial"?"partial":"complete"}))}return t.sort((m,g)=>m.seq-g.seq)}export{ke as a,Be as b,Ue as c};
@@ -1,2 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as o}from"./chunk-IAHKTEET.js";import{existsSync as c,mkdirSync as f,readFileSync as u,renameSync as l,writeFileSync as g}from"fs";import{dirname as p,join as a}from"path";function i(t,r){let n=r.startsWith("sha256:")?r.slice(7):r;return a(t,"blobs",n.slice(0,2),n.slice(2))}function B(t,r){return i(t,r)}function m(t){let r=Buffer.concat([Buffer.from("assurance.blob\0","utf8"),t]);return"sha256:"+o(r)}function d(t,r){let n=m(r),e=i(t,n);if(!c(e)){f(p(e),{recursive:!0});let s=`${e}.tmp-${process.pid}`;g(s,r),l(s,e)}return n}function S(t,r){let n=i(t,r);return c(n)?u(n):null}export{B as a,m as b,d as c,S as d};