@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,3 +1,3 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{d as X}from"./chunk-BB2W35TW.js";import{a as $}from"./chunk-YKTYVJBN.js";import{C as T,n as z,o as Y,p as H}from"./chunk-W3Z7AZNT.js";import{b as q,h as N}from"./chunk-XMTSHHYQ.js";import{a as W,d as S,f as L}from"./chunk-DBIBROYW.js";import{c as C}from"./chunk-UD7KKHPW.js";import{a as K,b as J}from"./chunk-33GXXC2L.js";var ce=3,de=1e4,Q=()=>new Promise(r=>setTimeout(r,25+Math.floor(Math.random()*50))),Z=r=>r==="design"||r==="maintain"?"session":r==="revert"||r==="shape-op"?"exclusive":"commit";function le(r,e,o){for(let s of r){for(let t of s.supersessions)if(t.kind==="node"&&(o.has(t.old)||t.new!==null&&o.has(t.new)))return!0;for(let t of s.nodes)if(t.label==="usecase"&&e.newBuCandidates.length>0||o.has(t.cid))return!0;if(s.design_generation&&e.generationTicket&&s.design_generation.uc_root===e.generationTicket.uc_root)return!0;for(let t of e.sourcePins)if(Object.prototype.hasOwnProperty.call(s.source_head_moves,t.source_id))return!0}return!1}async function De(r,e,o){let{contextDir:s,locks:t,probe:a}=r,m=r.sid??r.rootSid,f=e.newBuCandidates.map(b=>({tempRef:b.tempRef,probeText:b.probeText})),k=0,g=!0,p={hits:[],degraded:!1,probeBasis:null};for(;;){g&&(f.length>0&&(p=await a.batchSimilar(T(s),f)),g=!1);let b=T(s),_={seq:b.lastSeq,hash:b.latestHash},P=new Map,w=[],v=[],R=new Set;for(let d of e.ucTargets){let c=H(b,d.ref);if(c===null)return{ok:!1,kind:"validation",errors:[{code:"UNKNOWN_REF",detail:`${d.ref}: names no living node (unknown or tombstoned chain)`}]};d.expectedTip!==void 0&&d.expectedTip!==c.cid&&P.set(d.expectedTip,c.cid),R.add(c.cid),v.push(L(b,d.ref).key)}(e.verb==="revert"||e.verb==="shape-op")&&(v.length=0,v.push({kind:"context",mode:"exclusive"}));let y;try{y=t.acquire(S(v),{hold:Z(e.verb),verb:e.verb})}catch(d){if(d instanceof W&&(d.code==="UC_HELD"||d.code==="CONTEXT_HELD"))return{ok:!1,kind:"contended",err:d};throw d}let V=!1,M=!1;try{let d=await t.withKeySerialized(v,async()=>{let c=T(s),O=_.hash===c.latestHash?[]:N(s,_.seq,_.hash).records;for(let n of e.ucTargets){let i=H(c,n.ref);if(i===null){w.push({kind:"supersession",ref:n.ref,detail:`${n.ref} was retired while this commit staged \u2014 re-ground or abandon`});continue}for(let l of R)c.superseded.has(l)&&c.tipOf(l)===i.cid&&P.set(l,i.cid)}for(let n of e.sourcePins){let i=c.heads.get(n.source_id);i!=null&&i!==n.source_cid&&w.push({kind:"pin",ref:n.source_id,detail:`source '${n.source_id}' moved (pinned ${n.source_cid.slice(0,19)}, head ${i.slice(0,19)}) \u2014 re-ground or abandon`})}if(w.length>0)return{ok:!1,kind:"drifted",asks:w};if(e.generationTicket){let n=X(c,e.generationTicket);if(n!==null)return{ok:!1,kind:"validation",errors:[n]}}if(f.length>0&&O.length>0){let n=new Set(p.hits.map(u=>u.candidateCid)),i=a.recheckLocal(c,f,p.probeBasis,O);if(i.hits.some(u=>!n.has(u.candidateCid))||i.uncachedNewNodes.length>0)return M=!0,"restart"}if(e.verb!=="revert"&&e.verb!=="shape-op"){let n=S(e.ucTargets.map(u=>L(c,u.ref).key)),i=S(v);if(!(n.length===i.length&&n.every((u,h)=>JSON.stringify(u)===JSON.stringify(i[h]))))return"restart"}if(e.eventIds&&e.eventIds.length>0&&e.eventIds.every(n=>c.appliedEvents.has(n)))return{ok:!0,skipped:"already-applied"};let ae=Date.now()+de,j=c.latestHash,E=c;for(;;){let n={graph:E,expectPrev:j,redirects:P,probeHits:p.hits,degradedProbe:p.degraded,sid:m,eventIds:(l,u)=>{if(e.eventIds&&e.eventIds.length>0)return e.eventIds.slice(0,u);let h=Y(E,r.rootSid,l,u),U=r.reservedEventIds??[];if(U.length===0)return h;let D=`${r.rootSid}:${l}:`,A=0;for(let F of U){if(!F.startsWith(D))continue;let x=F.slice(D.length);/^\d+$/.test(x)&&(A=Math.max(A,Number.parseInt(x,10)))}if(A===0)return h;let G=Number.parseInt(h[0].slice(D.length),10);return!Number.isInteger(G)||G>A?h:Array.from({length:u},(F,x)=>z(r.rootSid,l,A+1+x))},assertLocks:()=>y.assertHeld()};if(r.revalidate){let l=r.revalidate(n);if(l.length>0)return{ok:!1,kind:"validation",errors:l}}y.assertHeld();let i;try{i=o(n)}catch(l){if(l instanceof q){let u=T(s),h=N(s,E.lastSeq,E.latestHash).records;if(!le(h,e,R)&&Date.now()<ae){await Q(),E=u,j=u.latestHash;continue}return"restart"}throw l}return"errors"in i?{ok:!1,kind:"validation",errors:i.errors}:(Z(e.verb)==="session"&&y.touch(),{ok:!0,result:i.result,record:i.record})}});if(d==="restart")V=!0;else return d}finally{y.release()}if(V){if(k+=1,k>=ce)return{ok:!1,kind:"unsettled",attempts:k};M&&(g=!0),await Q();continue}}}import{readFileSync as ue,writeFileSync as fe,renameSync as me,mkdirSync as pe}from"fs";import{dirname as he,join as ge}from"path";var B=1,be=720*60*1e3;function I(r){return ge(J,"embeddings",`alias-${r}.json`)}function ee(r,e=Date.now()){return r!==null&&e-r.fetchedAt<be}function re(r){try{let e=JSON.parse(ue(r,"utf-8"));return e.wrapperVersion!==B||typeof e.purposes!="object"||e.purposes===null?null:{wrapperVersion:B,writtenByVersion:String(e.writtenByVersion??""),purposes:e.purposes}}catch{return null}}function te(r,e,o=I(r)){let t=re(o)?.purposes?.[e];return!t||typeof t.alias!="string"||typeof t.dims!="number"||typeof t.fetchedAt!="number"?null:{alias:t.alias,dims:t.dims,fetchedAt:t.fetchedAt}}function se(r,e,o,s=I(r)){try{pe(he(s),{recursive:!0});let a=re(s)?.purposes??{};a[e]={alias:o.alias,dims:o.dims,fetchedAt:Date.now()};let m={wrapperVersion:B,writtenByVersion:K,purposes:a},f=`${s}.tmp`;fe(f,JSON.stringify(m,null,2)+`
2
+ import{d as X}from"./chunk-BB2W35TW.js";import{a as $}from"./chunk-YKTYVJBN.js";import{C as T,n as z,o as Y,p as H}from"./chunk-GP7WD4UY.js";import{K as N,x as q}from"./chunk-3N6IAVD5.js";import{a as W,e as S,g as L}from"./chunk-FQNQVC5O.js";import{c as C}from"./chunk-UD7KKHPW.js";import{a as K,b as J}from"./chunk-B2ZGG7WM.js";var ce=3,de=1e4,Q=()=>new Promise(r=>setTimeout(r,25+Math.floor(Math.random()*50))),Z=r=>r==="design"||r==="maintain"?"session":r==="revert"||r==="shape-op"?"exclusive":"commit";function le(r,e,o){for(let s of r){for(let t of s.supersessions)if(t.kind==="node"&&(o.has(t.old)||t.new!==null&&o.has(t.new)))return!0;for(let t of s.nodes)if(t.label==="usecase"&&e.newBuCandidates.length>0||o.has(t.cid))return!0;if(s.design_generation&&e.generationTicket&&s.design_generation.uc_root===e.generationTicket.uc_root)return!0;for(let t of e.sourcePins)if(Object.prototype.hasOwnProperty.call(s.source_head_moves,t.source_id))return!0}return!1}async function De(r,e,o){let{contextDir:s,locks:t,probe:a}=r,m=r.sid??r.rootSid,f=e.newBuCandidates.map(b=>({tempRef:b.tempRef,probeText:b.probeText})),k=0,g=!0,p={hits:[],degraded:!1,probeBasis:null};for(;;){g&&(f.length>0&&(p=await a.batchSimilar(T(s),f)),g=!1);let b=T(s),_={seq:b.lastSeq,hash:b.latestHash},P=new Map,w=[],v=[],R=new Set;for(let d of e.ucTargets){let c=H(b,d.ref);if(c===null)return{ok:!1,kind:"validation",errors:[{code:"UNKNOWN_REF",detail:`${d.ref}: names no living node (unknown or tombstoned chain)`}]};d.expectedTip!==void 0&&d.expectedTip!==c.cid&&P.set(d.expectedTip,c.cid),R.add(c.cid),v.push(L(b,d.ref).key)}(e.verb==="revert"||e.verb==="shape-op")&&(v.length=0,v.push({kind:"context",mode:"exclusive"}));let y;try{y=t.acquire(S(v),{hold:Z(e.verb),verb:e.verb})}catch(d){if(d instanceof W&&(d.code==="UC_HELD"||d.code==="CONTEXT_HELD"))return{ok:!1,kind:"contended",err:d};throw d}let V=!1,M=!1;try{let d=await t.withKeySerialized(v,async()=>{let c=T(s),O=_.hash===c.latestHash?[]:N(s,_.seq,_.hash).records;for(let n of e.ucTargets){let i=H(c,n.ref);if(i===null){w.push({kind:"supersession",ref:n.ref,detail:`${n.ref} was retired while this commit staged \u2014 re-ground or abandon`});continue}for(let l of R)c.superseded.has(l)&&c.tipOf(l)===i.cid&&P.set(l,i.cid)}for(let n of e.sourcePins){let i=c.heads.get(n.source_id);i!=null&&i!==n.source_cid&&w.push({kind:"pin",ref:n.source_id,detail:`source '${n.source_id}' moved (pinned ${n.source_cid.slice(0,19)}, head ${i.slice(0,19)}) \u2014 re-ground or abandon`})}if(w.length>0)return{ok:!1,kind:"drifted",asks:w};if(e.generationTicket){let n=X(c,e.generationTicket);if(n!==null)return{ok:!1,kind:"validation",errors:[n]}}if(f.length>0&&O.length>0){let n=new Set(p.hits.map(u=>u.candidateCid)),i=a.recheckLocal(c,f,p.probeBasis,O);if(i.hits.some(u=>!n.has(u.candidateCid))||i.uncachedNewNodes.length>0)return M=!0,"restart"}if(e.verb!=="revert"&&e.verb!=="shape-op"){let n=S(e.ucTargets.map(u=>L(c,u.ref).key)),i=S(v);if(!(n.length===i.length&&n.every((u,h)=>JSON.stringify(u)===JSON.stringify(i[h]))))return"restart"}if(e.eventIds&&e.eventIds.length>0&&e.eventIds.every(n=>c.appliedEvents.has(n)))return{ok:!0,skipped:"already-applied"};let ae=Date.now()+de,j=c.latestHash,E=c;for(;;){let n={graph:E,expectPrev:j,redirects:P,probeHits:p.hits,degradedProbe:p.degraded,sid:m,eventIds:(l,u)=>{if(e.eventIds&&e.eventIds.length>0)return e.eventIds.slice(0,u);let h=Y(E,r.rootSid,l,u),U=r.reservedEventIds??[];if(U.length===0)return h;let D=`${r.rootSid}:${l}:`,A=0;for(let F of U){if(!F.startsWith(D))continue;let x=F.slice(D.length);/^\d+$/.test(x)&&(A=Math.max(A,Number.parseInt(x,10)))}if(A===0)return h;let G=Number.parseInt(h[0].slice(D.length),10);return!Number.isInteger(G)||G>A?h:Array.from({length:u},(F,x)=>z(r.rootSid,l,A+1+x))},assertLocks:()=>y.assertHeld()};if(r.revalidate){let l=r.revalidate(n);if(l.length>0)return{ok:!1,kind:"validation",errors:l}}y.assertHeld();let i;try{i=o(n)}catch(l){if(l instanceof q){let u=T(s),h=N(s,E.lastSeq,E.latestHash).records;if(!le(h,e,R)&&Date.now()<ae){await Q(),E=u,j=u.latestHash;continue}return"restart"}throw l}return"errors"in i?{ok:!1,kind:"validation",errors:i.errors}:(Z(e.verb)==="session"&&y.touch(),{ok:!0,result:i.result,record:i.record})}});if(d==="restart")V=!0;else return d}finally{y.release()}if(V){if(k+=1,k>=ce)return{ok:!1,kind:"unsettled",attempts:k};M&&(g=!0),await Q();continue}}}import{readFileSync as ue,writeFileSync as fe,renameSync as me,mkdirSync as pe}from"fs";import{dirname as he,join as ge}from"path";var B=1,be=720*60*1e3;function I(r){return ge(J,"embeddings",`alias-${r}.json`)}function ee(r,e=Date.now()){return r!==null&&e-r.fetchedAt<be}function re(r){try{let e=JSON.parse(ue(r,"utf-8"));return e.wrapperVersion!==B||typeof e.purposes!="object"||e.purposes===null?null:{wrapperVersion:B,writtenByVersion:String(e.writtenByVersion??""),purposes:e.purposes}}catch{return null}}function te(r,e,o=I(r)){let t=re(o)?.purposes?.[e];return!t||typeof t.alias!="string"||typeof t.dims!="number"||typeof t.fetchedAt!="number"?null:{alias:t.alias,dims:t.dims,fetchedAt:t.fetchedAt}}function se(r,e,o,s=I(r)){try{pe(he(s),{recursive:!0});let a=re(s)?.purposes??{};a[e]={alias:o.alias,dims:o.dims,fetchedAt:Date.now()};let m={wrapperVersion:B,writtenByVersion:K,purposes:a},f=`${s}.tmp`;fe(f,JSON.stringify(m,null,2)+`
3
3
  `),me(f,s)}catch(t){C(`[embed] Failed to save alias cache: ${t instanceof Error?t.message:String(t)}`,"EMBED_CACHE_WRITE_FAILED")}}function ve(r){return r.TESTMUAI_ENV==="stage"?"stage":"prod"}function oe(r){let e=r.env??process.env,o=r.auth?.TESTMUAI_BASIC_AUTH||e.TESTMUAI_BASIC_AUTH;if(o)return{authorization:`Basic ${o}`};let s=r.auth?.TESTMUAI_API_KEY||e.TESTMUAI_API_KEY;return s?{authorization:`Bearer ${s}`}:{}}async function Oe(r,e={}){let o=e.env??process.env,s=ve(o),t=e.aliasCacheFile??I(s),a=e.now??Date.now,m=te(s,r,t);if(ee(m,a()))return{alias:m.alias,dims:m.dims};let k=`${$(o)}/assurance/embed/alias?purpose=${encodeURIComponent(r)}`,g=await(e.fetchImpl??fetch)(k,{method:"GET",headers:oe(e)});if(!g.ok)throw new Error(`embed alias resolve failed: ${g.status}`);let p=await g.json();return se(s,r,{alias:p.alias,dims:p.dims},t),{alias:p.alias,dims:p.dims}}async function je(r,e,o={}){let s=o.env??process.env,t=$(s),a=await(o.fetchImpl??fetch)(`${t}/assurance/embed`,{method:"POST",headers:{...oe(o),"content-type":"application/json"},body:JSON.stringify({purpose:r,input:e})});if(!a.ok)throw new Error(`embed failed: ${a.status}`);return await a.json()}import{readFileSync as ke,writeFileSync as ye,renameSync as Ee,mkdirSync as Ae}from"fs";import{dirname as Te,join as ne}from"path";function we(r){return ne(r,"embeddings")}function xe(r){let e=r.indexOf(":");return e>=0?r.slice(e+1):r}function ie(r,e,o){let s=xe(o);return ne(we(r),e,s.slice(0,2),`${s.slice(2)}.f32`)}function We(r,e,o){try{let s=ke(ie(r,e,o)),t=new Float32Array(Math.floor(s.length/4));for(let a=0;a<t.length;a++)t[a]=s.readFloatLE(a*4);return t}catch{return null}}function qe(r,e,o,s){try{let t=ie(r,e,o);Ae(Te(t),{recursive:!0});let a=Buffer.alloc(s.length*4);for(let f=0;f<s.length;f++)a.writeFloatLE(s[f],f*4);let m=`${t}.tmp`;ye(m,a),Ee(m,t)}catch(t){C(`[embed] Failed to cache vector: ${t instanceof Error?t.message:String(t)}`,"EMBED_CACHE_WRITE_FAILED")}}export{De as a,Oe as b,je as c,We as d,qe as e};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{g as h}from"./chunk-EV64VI66.js";import{e as l}from"./chunk-XMTSHHYQ.js";import{b as u}from"./chunk-DBIBROYW.js";import{d as f}from"./chunk-AKX4VRRR.js";import{existsSync as w,readFileSync as _,readdirSync as R}from"fs";import{join as p}from"path";function g(i,r){let{records:t}=l(i),o=new Set;for(let e of t)for(let n of e.review)n.resolution!=="pending"&&o.add(n.id);let s=[],d=new Set;for(let e=t.length-1;e>=0;e--)for(let n of t[e].dedup_hits??[]){if(n.new_cid===void 0)continue;let c=`${n.new_cid}|${n.candidate_cid}`;d.has(c)||(d.add(c),!o.has(n.new_cid)&&(r.superseded.has(n.new_cid)||r.superseded.has(n.candidate_cid)||r.trust.get(n.new_cid)==="derived"&&s.push({new_cid:n.new_cid,candidate_cid:n.candidate_cid,score:n.score,scorer:n.scorer})))}return s}var a=(i,r)=>i.displayNameOf(r)??r.slice(0,19);function m(i,r){return{design_children:i.edgesInto(r).filter(o=>(o.type==="belongs_to"||o.type==="scoped_to")&&!i.superseded.has(o.src)).length}}function v(i,r){let{records:t}=l(i),o=new Set,s=new Map;for(let e of t)for(let n of e.review)n.kind==="pending_archive"?s.set(n.id,n.reason):n.resolution!=="pending"&&o.add(n.id);let d=new Map;for(let[e,n]of s)r.superseded.has(e)||r.trust.get(e)!=="derived"||o.has(e)||d.set(e,n);return{all:s,live:d}}function y(i,r){let t=[],o=new Set;for(let e of g(i.contextDir,r)){o.add(e.new_cid);let n=e.scorer==="lexical_fallback"?" (lexical fallback \u2014 the probe ran degraded)":"";t.push({kind:"PAIR",ref:a(r,e.new_cid),title:String(r.getNode(e.new_cid)?.content.title??e.new_cid.slice(0,12)),why:`possible duplicate of ${a(r,e.candidate_cid)} \u2014 score ${e.score}${n}`,pair:{candidate_cid:e.candidate_cid,candidate_ref:a(r,e.candidate_cid),score:e.score,scorer:e.scorer}})}let{all:s,live:d}=v(i.contextDir,r);for(let[e,n]of d)t.push({kind:"REVIEW",ref:a(r,e),title:String(r.getNode(e)?.content.title??e.slice(0,12)),why:`archive held for interactive confirmation${n?` \u2014 ${n}`:""}`,held:!0,impact:m(r,e)});for(let e of k(i.contextDir))t.push({kind:"MODIFY_HELD",ref:`${e.sid}:${e.tempRef}`,title:String(e.content.title??e.tempRef),why:`${e.rationale} \u2014 held by paused/dead session ${e.sid}`,heldPayload:e});for(let{cid:e,content:n}of r.byLabel(f.USECASE))r.superseded.has(e)||r.trust.get(e)!=="derived"||o.has(e)||s.has(e)||t.push({kind:"REVIEW",ref:a(r,e),title:String(n.title??e.slice(0,12)),why:"unreviewed \u2014 approve, archive, or defer",impact:m(r,e)});return t}function F(i,r){let t={REVIEW:0,PAIR:0,MODIFY_HELD:0};for(let o of y(i,r))t[o.kind]++;return t}function b(i,r){try{let t=JSON.parse(_(p(i,"sessions",r,".lock"),"utf8"));return typeof t.pid=="number"&&u(t.pid)}catch{return!1}}function k(i){let r=[],t=p(i,"sessions");if(!w(t))return r;let o=[];try{o=R(t)}catch{return r}for(let s of o){if(!w(p(t,s,"state.json"))||b(i,s))continue;let d=[],e=!1;try{let c=h(i,s).kane;c?.pending?.proposals?.length&&(d=c.pending.proposals,e=!0)}catch{e=!1}if(!e)try{d=JSON.parse(_(p(t,s,"state.json"),"utf8")).pending?.proposals??[]}catch{continue}for(let n of d)r.push({sid:s,tempRef:String(n.tempRef??n.temp_ref??"held"),...typeof n.event_id=="string"?{event_id:n.event_id}:{},label:String(n.label??"usecase"),content:n.content??{},rationale:String(n.rationale??"held payload")})}return r}export{m as a,v as b,y as c,F as d};
2
+ import{g as h}from"./chunk-CRZUBDJ3.js";import{F as l}from"./chunk-3N6IAVD5.js";import{b as u}from"./chunk-FQNQVC5O.js";import{d as f}from"./chunk-AKX4VRRR.js";import{existsSync as w,readFileSync as _,readdirSync as R}from"fs";import{join as p}from"path";function g(i,r){let{records:t}=l(i),o=new Set;for(let e of t)for(let n of e.review)n.resolution!=="pending"&&o.add(n.id);let s=[],d=new Set;for(let e=t.length-1;e>=0;e--)for(let n of t[e].dedup_hits??[]){if(n.new_cid===void 0)continue;let c=`${n.new_cid}|${n.candidate_cid}`;d.has(c)||(d.add(c),!o.has(n.new_cid)&&(r.superseded.has(n.new_cid)||r.superseded.has(n.candidate_cid)||r.trust.get(n.new_cid)==="derived"&&s.push({new_cid:n.new_cid,candidate_cid:n.candidate_cid,score:n.score,scorer:n.scorer})))}return s}var a=(i,r)=>i.displayNameOf(r)??r.slice(0,19);function m(i,r){return{design_children:i.edgesInto(r).filter(o=>(o.type==="belongs_to"||o.type==="scoped_to")&&!i.superseded.has(o.src)).length}}function v(i,r){let{records:t}=l(i),o=new Set,s=new Map;for(let e of t)for(let n of e.review)n.kind==="pending_archive"?s.set(n.id,n.reason):n.resolution!=="pending"&&o.add(n.id);let d=new Map;for(let[e,n]of s)r.superseded.has(e)||r.trust.get(e)!=="derived"||o.has(e)||d.set(e,n);return{all:s,live:d}}function y(i,r){let t=[],o=new Set;for(let e of g(i.contextDir,r)){o.add(e.new_cid);let n=e.scorer==="lexical_fallback"?" (lexical fallback \u2014 the probe ran degraded)":"";t.push({kind:"PAIR",ref:a(r,e.new_cid),title:String(r.getNode(e.new_cid)?.content.title??e.new_cid.slice(0,12)),why:`possible duplicate of ${a(r,e.candidate_cid)} \u2014 score ${e.score}${n}`,pair:{candidate_cid:e.candidate_cid,candidate_ref:a(r,e.candidate_cid),score:e.score,scorer:e.scorer}})}let{all:s,live:d}=v(i.contextDir,r);for(let[e,n]of d)t.push({kind:"REVIEW",ref:a(r,e),title:String(r.getNode(e)?.content.title??e.slice(0,12)),why:`archive held for interactive confirmation${n?` \u2014 ${n}`:""}`,held:!0,impact:m(r,e)});for(let e of k(i.contextDir))t.push({kind:"MODIFY_HELD",ref:`${e.sid}:${e.tempRef}`,title:String(e.content.title??e.tempRef),why:`${e.rationale} \u2014 held by paused/dead session ${e.sid}`,heldPayload:e});for(let{cid:e,content:n}of r.byLabel(f.USECASE))r.superseded.has(e)||r.trust.get(e)!=="derived"||o.has(e)||s.has(e)||t.push({kind:"REVIEW",ref:a(r,e),title:String(n.title??e.slice(0,12)),why:"unreviewed \u2014 approve, archive, or defer",impact:m(r,e)});return t}function F(i,r){let t={REVIEW:0,PAIR:0,MODIFY_HELD:0};for(let o of y(i,r))t[o.kind]++;return t}function b(i,r){try{let t=JSON.parse(_(p(i,"sessions",r,".lock"),"utf8"));return typeof t.pid=="number"&&u(t.pid)}catch{return!1}}function k(i){let r=[],t=p(i,"sessions");if(!w(t))return r;let o=[];try{o=R(t)}catch{return r}for(let s of o){if(!w(p(t,s,"state.json"))||b(i,s))continue;let d=[],e=!1;try{let c=h(i,s).kane;c?.pending?.proposals?.length&&(d=c.pending.proposals,e=!0)}catch{e=!1}if(!e)try{d=JSON.parse(_(p(t,s,"state.json"),"utf8")).pending?.proposals??[]}catch{continue}for(let n of d)r.push({sid:s,tempRef:String(n.tempRef??n.temp_ref??"held"),...typeof n.event_id=="string"?{event_id:n.event_id}:{},label:String(n.label??"usecase"),content:n.content??{},rationale:String(n.rationale??"held payload")})}return r}export{m as a,v as b,y as c,F as d};
@@ -0,0 +1,5 @@
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 J,mkdirSync as C,openSync as U,readFileSync as M,readdirSync as X,renameSync as $,rmSync as h,watch as F,writeFileSync as _}from"fs";import{join as g}from"path";import{randomBytes as q}from"crypto";var R=1440*60*1e3,m=class extends Error{constructor(a,u,f,k){super(`${a}: ${f}`);this.code=a;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(i){return i.code==="EPERM"}}function G(e,i){let a=i.getTime()-new Date(e.ts).getTime();return!P(e.pid)||a>=R||Number.isNaN(a)}var L=e=>g(e,"locks"),H=e=>g(L(e),"waiters");function T(e,i){return i.kind==="context"?g(L(e),"context.lock"):i.kind==="extract"?g(L(e),"extract.lock"):g(L(e),`uc-${i.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((i,a)=>K(i)<K(a)?-1:K(i)>K(a)?1:0)}function p(e){try{return JSON.parse(M(e,"utf8"))}catch{return null}}function W(e,i,a){let u=`${e}.break-${a}`;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===i)return h(u,{force:!0}),!0;try{$(u,e)}catch{h(u,{force:!0})}return!1}var y=new Map,O=new Map;function V(e,i,a){let u=o=>`${e}|${i}|${x(o)}`;function f(o,d,s=0){if(s>20)throw new m("LOCK_CONTENTION_UNSETTLED",o,`${v(o)}: lock contention did not settle`);let c=T(e,o);C(L(e),{recursive:!0});let n=q(8).toString("hex");try{let t=U(c,"wx",384);return _(t,JSON.stringify({...d,nonce:n})+`
3
+ `),D(t),n}catch(t){if(t.code!=="EEXIST")throw t;let r=p(c),l=E(a);if(r!==null&&!G(r,l)){let S=o.kind==="context"?"CONTEXT_HELD":o.kind==="extract"?"EXTRACT_HELD":"UC_HELD";throw new m(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 W(c,r?.nonce,n)&&N({type:"lock_steal",key:v(o),stale_owner:r?.owner_sid??"corrupt",by:i,ts:l.toISOString()}),f(o,d,s+1)}}function k(o,d){let s=!1;return{keys:d,assertHeld(){for(let{key:c,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 m("LOCK_LOST",c,`${v(c)} grant was taken over or removed`)}},touch(){for(let{sk:c}of o){let n=y.get(c);if(!n)continue;let t=p(n.path);t!==null&&t.nonce===n.nonce&&_(n.path,JSON.stringify({...t,ts:E(a).toISOString()})+`
4
+ `,{mode:384})}},release(){if(!s){s=!0;for(let{sk:c}of[...o].reverse()){let n=y.get(c);if(n&&(n.count-=1,n.count<=0)){y.delete(c);let t=p(n.path);t!==null&&t.nonce===n.nonce&&h(n.path,{force:!0})}}}}}}function w(o,d){let s=I(o),c=[];try{for(let n of s){let t=u(n),r=y.get(t);if(r)r.count+=1;else{let l=f(n,{owner_sid:i,pid:process.pid,ts:E(a).toISOString(),verb:d.verb??"unknown",hold:d.hold,...n.kind==="uc"?{logical_display:n.id.toUpperCase()}:{}});y.set(t,{nonce:l,count:1,path:T(e,n),key:n})}c.push({key:n,sk:t})}return k(c,s)}catch(n){for(let{sk:t}of[...c].reverse()){let r=y.get(t);if(r&&(r.count-=1,r.count<=0)){y.delete(t);let l=p(r.path);l!==null&&l.nonce===r.nonce&&h(r.path,{force:!0})}}throw n}}return{acquire:w,tryAcquire(o,d){try{return w(o,d)}catch(s){if(s instanceof m&&(s.code==="UC_HELD"||s.code==="CONTEXT_HELD"||s.code==="EXTRACT_HELD"))return{contended:s};throw s}},holder(o){return p(T(e,o))},async wait(o,d){let s=T(e,o);C(H(e),{recursive:!0});let c=g(H(e),`${x(o)}.${i}.${process.pid}.json`);try{_(c,JSON.stringify({sid:i,pid:process.pid,ts:E(a).toISOString()})+`
5
+ `,{mode:384})}catch{}let n=Date.now()+d.timeoutMs,t=null,r=null;try{try{t=F(L(e),()=>{r?.()}),t.on("error",()=>{r?.(),t=null})}catch{t=null}for(;;){if(d.signal?.aborted)return"cancelled";let l=p(s);if(l===null||G(l,E(a)))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(),h(c,{force:!0})}},async withKeySerialized(o,d){let c=I(o).map(l=>`${e}|${x(l)}`),n=c.map(l=>O.get(l)??Promise.resolve()),t,r=new Promise(l=>{t=l});for(let l of c)O.set(l,r);await Promise.all(n);try{return await d()}finally{t();for(let l of c)O.get(l)===r&&O.delete(l)}},releaseAll(o){let d=`${e}|${o}|`;for(let[s,c]of[...y]){if(!s.startsWith(d))continue;y.delete(s);let n=p(c.path);n!==null&&n.nonce===c.nonce&&h(c.path,{force:!0})}}}}function Y(e,i){let a=e.resolve(i);if(a===null)return{key:{kind:"uc",id:i.toLowerCase()},display:i};let u=e.displayNameOf(a.tip)??e.displayNameOf(a.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,s]of e.superseded)typeof s=="string"&&f.set(s,d);let k=a.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}}function Z(e){let i=L(e);if(!J(i))return[];let a=[];for(let u of X(i)){if(!u.endsWith(".lock"))continue;let f=p(g(i,u));f!==null&&a.push({key:u.replace(/\.lock$/,""),grant:f})}return a}export{m as a,P as b,G as c,H as d,I as e,V as f,Y as g,Z as h};
@@ -1,4 +1,4 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{e as $e}from"./chunk-PYQS5ST6.js";import{a as te}from"./chunk-477DYMXZ.js";import{a as K}from"./chunk-5Y2G4NC7.js";import{a as Be}from"./chunk-SEKJZOKW.js";import{a as ve}from"./chunk-AQWTK6IN.js";import{y as i}from"./chunk-33GXXC2L.js";import{b as ye}from"./chunk-DFS4RMVP.js";import{a as k}from"./chunk-HCBYKLMW.js";import{a as s,b as o,i as Se,j as Te,k as ee}from"./chunk-C44QQJR4.js";import{a as V}from"./chunk-6YGTRKDT.js";import{e as R}from"./chunk-UR6MHSHU.js";var A=R(V(),1);var C=R(V(),1);function de(e){let t=e.flatMap(u=>[u,...u.children??[]]),n=t.filter(u=>u.status==="passed").length,l=t.filter(u=>u.status==="failed").length,a=t.filter(u=>u.status==="passed"||u.status==="failed").length;return{passed:n,failed:l,total:a}}function we(e){let t=$e(e.screenshotDispatcher,e.stepLogger,e.onReasoning,e.onStepComplete),[n,l]=(0,C.useState)(0),[a,u]=(0,C.useState)("idle"),c=(0,C.useRef)("idle"),v=(0,C.useRef)(0),S=(0,C.useRef)(!1),T=(0,C.useRef)(null),d=(0,C.useRef)(null),L=(0,C.useCallback)(h=>{c.current=h,u(h)},[]),O=(0,C.useCallback)(async h=>{let b=await e.getNextConfig(h);if(!b){L("done"),e.onAllComplete?.();return}let B=h?v.current+1:0;v.current=B,l(B),e.onStepStart?.(b,B),T.current=null,d.current=null,L("running"),await t.startRun(b,e.spawnOpts)},[t,e,L]);(0,C.useEffect)(()=>{S.current||(S.current=!0,O(null))},[]),(0,C.useEffect)(()=>{if(!t.lastRunEnd||t.lastRunEnd===T.current||c.current!=="running")return;T.current=t.lastRunEnd,c.current="transitioning",u("transitioning");let h=t.lastRunEnd,b=de(t.steps),B=t.bifurcationInfo,F={status:h.status==="passed"?"passed":"failed",duration_s:h.duration??0,reason:h.reason,runEnd:h,hadError:!1,stepsPassed:b.passed,stepsFailed:b.failed,stepsTotal:b.total,bifurcationFlows:B&&!B.isSingleFlow?B.flows:null,evidence:t.getEvidenceState()};if(!(e.onStepEnd?.(F,v.current)??!0)){L("done"),e.onAllComplete?.();return}O(F)},[t.lastRunEnd]),(0,C.useEffect)(()=>{if(!t.runError||t.runError===d.current||t.lastRunEnd||c.current!=="running")return;d.current=t.runError,c.current="transitioning",u("transitioning");let h=de(t.steps),b={status:"failed",duration_s:0,reason:t.runError,runEnd:null,hadError:!0,stepsPassed:h.passed,stepsFailed:h.failed,stepsTotal:h.total,bifurcationFlows:null,evidence:t.getEvidenceState()};if(!(e.onStepEnd?.(b,v.current)??!0)){L("done"),e.onAllComplete?.();return}O(b)},[t.runError,t.lastRunEnd]);let y=(0,C.useCallback)(()=>{t.cancelRun()},[t]);return{runner:t,currentStepIndex:n,phase:a,cancel:y}}var pe=R(V(),1);var ne=R(k(),1),Ee=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function ke({label:e,hasBifurcation:t=!1}){let[n,l]=(0,pe.useState)(0),[a,u]=(0,pe.useState)(0);K(()=>{l(v=>(v+1)%Ee.length)},80),K(()=>{u(v=>(v+1)%4)},400);let c=e??(t?"Planning approach":"Analyzing objective");return(0,ne.jsxs)(s,{marginLeft:1,children:[(0,ne.jsxs)(o,{color:i.orange,children:[Ee[n]," "]}),(0,ne.jsxs)(o,{color:i.dim,children:[c,".".repeat(a+1)]})]})}function Ie(e){if(!e.isRunning||e.replayInfo)return null;let t=e.bifurcationInfo;if(t&&!t.isSingleFlow){let n=e.steps.findIndex(a=>a.status==="running");return(n===-1?e.cmInitCounts.length===0:n>=e.cmInitCounts.length)?{label:n>0?`Planning flow ${n+1}`:void 0,hasBifurcation:!0}:null}return e.cmInitCounts.length>0||e.steps.some(n=>n.children?.length)?null:{hasBifurcation:!!t}}var I=R(V(),1);var Ce=R(V(),1);var re=R(k(),1),He="#ffc580",Ue="#ffd9a8",Le="#ffffff";function oe({text:e,active:t=!0}){let[n,l]=(0,Ce.useState)(0),a=4;if(K(()=>{l(c=>(c+1)%(e.length+a*2))},t?80:null),!t)return(0,re.jsx)(o,{color:Le,children:e});let u=e.split("").map((c,v)=>{let S=n-a,T=Math.abs(v-S-a/2),d;return T<=a/2?d=He:T<=a?d=Ue:d=Le,(0,re.jsx)(o,{color:d,children:c},v)});return(0,re.jsx)(o,{children:u})}var _=R(k(),1),We={starting:i.orange,running:i.orange,passed:i.green,failed:i.red,cancelled:i.dim,timed_out:i.orange};function ie({currentStep:e,maxSteps:t,elapsed:n,status:l}){let a=We[l]??i.orange,u=n<60?`${n.toFixed(1)}s`:`${Math.floor(n/60)}m ${Math.round(n%60)}s`;return(0,_.jsxs)(s,{marginLeft:3,children:[(0,_.jsx)(o,{color:i.dim,children:"Steps "}),(0,_.jsx)(o,{bold:!0,children:e}),(0,_.jsxs)(o,{color:i.dim,children:["/",t]}),(0,_.jsx)(o,{children:" "}),(0,_.jsx)(o,{color:i.dim,children:"Elapsed "}),(0,_.jsx)(o,{bold:!0,children:u}),(0,_.jsx)(o,{children:" "}),(0,_.jsx)(o,{color:i.dim,children:"Status "}),(0,_.jsx)(o,{bold:!0,color:a,children:l})]})}var Ve={click:"\u25CF",type:"\u229E",scroll:"\u2195",navigate:"\u2192",analyze:"\u25CE",assert:"\u25C8","if-else":"\u2442",select:"\u25BC",press_key:"\u21B5",wait:"\u2026",tool_call:"\u2299"};function Oe(e){return Ve[e]??"\u25CF"}var q=R(k(),1);function fe({steps:e,flows:t,cmInitCounts:n,renderStep:l}){return(0,q.jsxs)(s,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:[(0,q.jsxs)(o,{color:i.dim,children:["\u2501\u2501 Bifurcated into ",t?.length??e.length," flows \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"]}),e.map((a,u)=>(0,q.jsxs)(s,{flexDirection:"column",marginTop:u>0?1:0,children:[(0,q.jsxs)(o,{color:i.orange,children:["Flow ",u+1,": ",t?.[u]??a.objective]}),n&&n[u]!=null&&(0,q.jsxs)(o,{color:i.dim,children:[" \u25AA Generated task with ",n[u]," checkpoints"]}),a.children&&a.children.length>0?a.children.map(c=>{let v=!!c.branchObjective,S=`f${u}-${c.childId??"p"}-${c.index}`;return v?(0,q.jsxs)(s,{flexDirection:"column",children:[l({...c,children:void 0},S),(c.children??[]).map(T=>(0,q.jsx)(s,{marginLeft:2,children:l(T,`${S}-${T.childId??"p"}-${T.index}`)},`${S}-${T.childId??"p"}-${T.index}`))]},`${S}-host`):l(c,S)}):a.status==="pending"&&(0,q.jsx)(o,{color:i.dim,children:" \u25CB Waiting..."})]},u))]})}var H=R(k(),1);function Pe({label:e,shimmer:t=!1}){return(0,H.jsxs)(s,{marginLeft:6,children:[(0,H.jsx)(te,{}),(0,H.jsx)(o,{children:" "}),t?(0,H.jsx)(oe,{text:e,active:!0}):(0,H.jsx)(o,{color:i.dim,children:e})]})}var De=R(V(),1);var me=R(k(),1);function ze(e,t){let n=[];for(let l of e.split(`
2
+ import{e as $e}from"./chunk-GPIXV7AV.js";import{a as te}from"./chunk-X74PP5NJ.js";import{a as K}from"./chunk-5Y2G4NC7.js";import{a as Be}from"./chunk-7L25ZNNP.js";import{a as ve}from"./chunk-ARG56PJG.js";import{y as i}from"./chunk-B2ZGG7WM.js";import{b as ye}from"./chunk-DFS4RMVP.js";import{a as k}from"./chunk-HCBYKLMW.js";import{a as s,b as o,i as Se,j as Te,k as ee}from"./chunk-C44QQJR4.js";import{a as V}from"./chunk-6YGTRKDT.js";import{e as R}from"./chunk-UR6MHSHU.js";var A=R(V(),1);var C=R(V(),1);function de(e){let t=e.flatMap(u=>[u,...u.children??[]]),n=t.filter(u=>u.status==="passed").length,l=t.filter(u=>u.status==="failed").length,a=t.filter(u=>u.status==="passed"||u.status==="failed").length;return{passed:n,failed:l,total:a}}function we(e){let t=$e(e.screenshotDispatcher,e.stepLogger,e.onReasoning,e.onStepComplete),[n,l]=(0,C.useState)(0),[a,u]=(0,C.useState)("idle"),c=(0,C.useRef)("idle"),v=(0,C.useRef)(0),S=(0,C.useRef)(!1),T=(0,C.useRef)(null),d=(0,C.useRef)(null),L=(0,C.useCallback)(h=>{c.current=h,u(h)},[]),O=(0,C.useCallback)(async h=>{let b=await e.getNextConfig(h);if(!b){L("done"),e.onAllComplete?.();return}let B=h?v.current+1:0;v.current=B,l(B),e.onStepStart?.(b,B),T.current=null,d.current=null,L("running"),await t.startRun(b,e.spawnOpts)},[t,e,L]);(0,C.useEffect)(()=>{S.current||(S.current=!0,O(null))},[]),(0,C.useEffect)(()=>{if(!t.lastRunEnd||t.lastRunEnd===T.current||c.current!=="running")return;T.current=t.lastRunEnd,c.current="transitioning",u("transitioning");let h=t.lastRunEnd,b=de(t.steps),B=t.bifurcationInfo,F={status:h.status==="passed"?"passed":"failed",duration_s:h.duration??0,reason:h.reason,runEnd:h,hadError:!1,stepsPassed:b.passed,stepsFailed:b.failed,stepsTotal:b.total,bifurcationFlows:B&&!B.isSingleFlow?B.flows:null,evidence:t.getEvidenceState()};if(!(e.onStepEnd?.(F,v.current)??!0)){L("done"),e.onAllComplete?.();return}O(F)},[t.lastRunEnd]),(0,C.useEffect)(()=>{if(!t.runError||t.runError===d.current||t.lastRunEnd||c.current!=="running")return;d.current=t.runError,c.current="transitioning",u("transitioning");let h=de(t.steps),b={status:"failed",duration_s:0,reason:t.runError,runEnd:null,hadError:!0,stepsPassed:h.passed,stepsFailed:h.failed,stepsTotal:h.total,bifurcationFlows:null,evidence:t.getEvidenceState()};if(!(e.onStepEnd?.(b,v.current)??!0)){L("done"),e.onAllComplete?.();return}O(b)},[t.runError,t.lastRunEnd]);let y=(0,C.useCallback)(()=>{t.cancelRun()},[t]);return{runner:t,currentStepIndex:n,phase:a,cancel:y}}var pe=R(V(),1);var ne=R(k(),1),Ee=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function ke({label:e,hasBifurcation:t=!1}){let[n,l]=(0,pe.useState)(0),[a,u]=(0,pe.useState)(0);K(()=>{l(v=>(v+1)%Ee.length)},80),K(()=>{u(v=>(v+1)%4)},400);let c=e??(t?"Planning approach":"Analyzing objective");return(0,ne.jsxs)(s,{marginLeft:1,children:[(0,ne.jsxs)(o,{color:i.orange,children:[Ee[n]," "]}),(0,ne.jsxs)(o,{color:i.dim,children:[c,".".repeat(a+1)]})]})}function Ie(e){if(!e.isRunning||e.replayInfo)return null;let t=e.bifurcationInfo;if(t&&!t.isSingleFlow){let n=e.steps.findIndex(a=>a.status==="running");return(n===-1?e.cmInitCounts.length===0:n>=e.cmInitCounts.length)?{label:n>0?`Planning flow ${n+1}`:void 0,hasBifurcation:!0}:null}return e.cmInitCounts.length>0||e.steps.some(n=>n.children?.length)?null:{hasBifurcation:!!t}}var I=R(V(),1);var Ce=R(V(),1);var re=R(k(),1),He="#ffc580",Ue="#ffd9a8",Le="#ffffff";function oe({text:e,active:t=!0}){let[n,l]=(0,Ce.useState)(0),a=4;if(K(()=>{l(c=>(c+1)%(e.length+a*2))},t?80:null),!t)return(0,re.jsx)(o,{color:Le,children:e});let u=e.split("").map((c,v)=>{let S=n-a,T=Math.abs(v-S-a/2),d;return T<=a/2?d=He:T<=a?d=Ue:d=Le,(0,re.jsx)(o,{color:d,children:c},v)});return(0,re.jsx)(o,{children:u})}var _=R(k(),1),We={starting:i.orange,running:i.orange,passed:i.green,failed:i.red,cancelled:i.dim,timed_out:i.orange};function ie({currentStep:e,maxSteps:t,elapsed:n,status:l}){let a=We[l]??i.orange,u=n<60?`${n.toFixed(1)}s`:`${Math.floor(n/60)}m ${Math.round(n%60)}s`;return(0,_.jsxs)(s,{marginLeft:3,children:[(0,_.jsx)(o,{color:i.dim,children:"Steps "}),(0,_.jsx)(o,{bold:!0,children:e}),(0,_.jsxs)(o,{color:i.dim,children:["/",t]}),(0,_.jsx)(o,{children:" "}),(0,_.jsx)(o,{color:i.dim,children:"Elapsed "}),(0,_.jsx)(o,{bold:!0,children:u}),(0,_.jsx)(o,{children:" "}),(0,_.jsx)(o,{color:i.dim,children:"Status "}),(0,_.jsx)(o,{bold:!0,color:a,children:l})]})}var Ve={click:"\u25CF",type:"\u229E",scroll:"\u2195",navigate:"\u2192",analyze:"\u25CE",assert:"\u25C8","if-else":"\u2442",select:"\u25BC",press_key:"\u21B5",wait:"\u2026",tool_call:"\u2299"};function Oe(e){return Ve[e]??"\u25CF"}var q=R(k(),1);function fe({steps:e,flows:t,cmInitCounts:n,renderStep:l}){return(0,q.jsxs)(s,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:[(0,q.jsxs)(o,{color:i.dim,children:["\u2501\u2501 Bifurcated into ",t?.length??e.length," flows \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"]}),e.map((a,u)=>(0,q.jsxs)(s,{flexDirection:"column",marginTop:u>0?1:0,children:[(0,q.jsxs)(o,{color:i.orange,children:["Flow ",u+1,": ",t?.[u]??a.objective]}),n&&n[u]!=null&&(0,q.jsxs)(o,{color:i.dim,children:[" \u25AA Generated task with ",n[u]," checkpoints"]}),a.children&&a.children.length>0?a.children.map(c=>{let v=!!c.branchObjective,S=`f${u}-${c.childId??"p"}-${c.index}`;return v?(0,q.jsxs)(s,{flexDirection:"column",children:[l({...c,children:void 0},S),(c.children??[]).map(T=>(0,q.jsx)(s,{marginLeft:2,children:l(T,`${S}-${T.childId??"p"}-${T.index}`)},`${S}-${T.childId??"p"}-${T.index}`))]},`${S}-host`):l(c,S)}):a.status==="pending"&&(0,q.jsx)(o,{color:i.dim,children:" \u25CB Waiting..."})]},u))]})}var H=R(k(),1);function Pe({label:e,shimmer:t=!1}){return(0,H.jsxs)(s,{marginLeft:6,children:[(0,H.jsx)(te,{}),(0,H.jsx)(o,{children:" "}),t?(0,H.jsx)(oe,{text:e,active:!0}):(0,H.jsx)(o,{color:i.dim,children:e})]})}var De=R(V(),1);var me=R(k(),1);function ze(e,t){let n=[];for(let l of e.split(`
3
3
  `)){if(l===""){n.push("");continue}let a="";for(let u of l.split(" ")){let c=u;for(;c.length>t;)a&&(n.push(a),a=""),n.push(c.slice(0,t)),c=c.slice(t);a===""?a=c:a.length+1+c.length<=t?a+=" "+c:(n.push(a),a=c)}n.push(a)}return n}function je({text:e,maxLines:t=3}){let{stdout:n}=ee(),l=Math.max(20,(n?.columns??80)-7),a=!e.trim(),[u,c]=(0,De.useState)(!0);K(()=>c(T=>!T),500);let v=(a?"Thinking\u2026":e)+(u?"\u258C":" "),S=ze(v,l).slice(-t);for(;S.length<t;)S.push("");return(0,me.jsx)(s,{borderStyle:"round",borderColor:i.muted,paddingX:1,marginLeft:3,flexDirection:"column",children:S.map((T,d)=>(0,me.jsx)(o,{color:a?i.dim:i.secondary,wrap:"truncate-end",children:T.length?T:" "},d))})}var U=R(k(),1);function se({activity:e,describe:t,describeVisible:n}){return(0,U.jsxs)(U.Fragment,{children:[e?(0,U.jsx)(Pe,{label:e.label,shimmer:e.shimmer}):null,n?(0,U.jsx)(je,{text:t??""}):null]})}var r=R(k(),1);function le(e){for(let t of e){if(t.children&&t.children.length>0){let n=le(t.children);if(n)return n}if(t.status==="running")return t}}function z(e){return e.status==="running"&&!e.branchObjective&&(!e.children||e.children.length===0)}function Fe(e){let t=[];for(let n of e)z(n)||(n.children&&n.children.length>0?t.push({...n,children:Fe(n.children)}):t.push(n));return t}function ge(e,t){if(!e)return null;let n=e.objective??"";return n.length>0&&!/^Step \d+$/.test(n)?{label:n+"\u2026",shimmer:!1}:{label:t?"Looking at the screen\u2026":"Deciding next action\u2026",shimmer:!0}}function P({step:e,indent:t=2}){let n=e.actionType?Oe(e.actionType):null,l=e.status==="running",a=e.status==="passed",u=e.status==="failed",c=e.status==="pending"||e.status==="stopped",{stdout:v}=ee(),S=v?.columns??80,T=Math.max(20,S-t-21),d=e.objective??"",L=d.length>T?d.slice(0,T-1)+"\u2026":d,O=(e.duration??0)*1e3,y=e.duration!=null?O<1e3?`${Math.round(O)}ms`:`${(O/1e3).toFixed(1)}s`:"";return(0,r.jsxs)(s,{flexDirection:"column",children:[(0,r.jsxs)(s,{marginLeft:t,children:[(0,r.jsx)(s,{width:4,children:(0,r.jsxs)(o,{color:i.muted,children:[String(e.index).padStart(2," ")," "]})}),(0,r.jsx)(s,{width:3,children:l?(0,r.jsx)(te,{}):a?(0,r.jsx)(o,{color:i.green,bold:!0,children:"\u2713"}):u?(0,r.jsx)(o,{color:i.red,bold:!0,children:"\u2717"}):(0,r.jsx)(o,{color:i.muted,children:"\u25CB"})}),(0,r.jsx)(s,{flexGrow:1,children:l?(0,r.jsx)(oe,{text:L,active:!0}):u?(0,r.jsx)(o,{color:i.red,children:L}):c?(0,r.jsx)(o,{color:i.dim,children:L}):(0,r.jsx)(o,{color:i.dim,children:L})}),(a||u)&&n?(0,r.jsx)(s,{width:3,marginLeft:1,children:(0,r.jsx)(o,{color:i.muted,children:n})}):(0,r.jsx)(s,{width:3,marginLeft:1}),(0,r.jsx)(s,{width:7,justifyContent:"flex-end",children:(0,r.jsx)(o,{color:i.dim,children:y})})]}),e.children&&e.children.length>0&&(0,r.jsx)(s,{flexDirection:"column",children:e.children.map((h,b)=>(0,r.jsx)(P,{step:h,indent:t+2},`child-${b}`))})]})}function Xe(e){return e.type==="cm_init"?(0,r.jsx)(s,{marginLeft:2,paddingLeft:1,children:(0,r.jsxs)(o,{color:i.dim,children:["\u25AA Generated task with ",e.count," checkpoints"]})}):(0,r.jsx)(s,{marginLeft:2,paddingLeft:1,children:(0,r.jsx)(P,{step:e.step})})}function _e({steps:e,bifurcated:t,flows:n,cmInitCounts:l,maxSteps:a=50,staticSteps:u=!1,onStepCommit:c,describe:v,describeVisible:S,describeRevealing:T}){let d=(0,I.useRef)(new Set),L=(0,I.useRef)(!1),O=(0,I.useRef)(new Set),y=(0,I.useRef)(!1),h=(0,I.useRef)(new Set),b=(0,I.useRef)(0);(0,I.useEffect)(()=>{e.length===0&&b.current>0&&(d.current.clear(),L.current=!1,O.current.clear(),y.current=!1,h.current.clear()),b.current=e.length},[e.length]);let B=e.flatMap(p=>[p,...p.children??[]]),F=B.some(p=>p.status==="running"),M=B.some(p=>p.status==="failed"),X=B.length===0||B.every(p=>p.status==="pending"),Y=B.filter(p=>p.status==="passed"||p.status==="failed").length,N;X?N="starting":F?N="running":M?N="failed":N="passed";let J=(0,I.useRef)(null),[ce,he]=(0,I.useState)(0);(0,I.useEffect)(()=>{B.length===0||X?(J.current=null,he(0)):F&&J.current==null&&(J.current=Date.now())},[F,X,B.length]),(0,I.useEffect)(()=>{if(!F)return;let p=setInterval(()=>{J.current!=null&&he((Date.now()-J.current)/1e3)},500);return()=>clearInterval(p)},[F]);let ae=(0,I.useRef)(new Set),[,xe]=(0,I.useState)(0),be=(0,I.useRef)(!1);(0,I.useEffect)(()=>{if(!c||!u||t)return;let p=[];!be.current&&l&&l[0]!=null&&(be.current=!0,l[0]>0&&p.push({key:"cm_init_0",type:"cm_init",count:l[0]}));for(let g of e)(g.status==="passed"||g.status==="failed")&&!ae.current.has(g.index)&&(ae.current.add(g.index),p.push({key:`step_${g.index}`,type:"step",step:{...g,children:g.children?[...g.children]:void 0}}));if(p.length>0){for(let g of p)c(Xe(g));xe(g=>g+1)}},[e,t,l,u,c]),(0,I.useEffect)(()=>{if(!c||u)return;let p=d.current.size;if(!t&&!y.current&&l&&l[0]!=null&&(y.current=!0,l[0]>0&&c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsxs)(o,{color:i.dim,children:["\u25A0 Generated task with ",l[0]," checkpoints"]})}))),t&&n&&!L.current&&(L.current=!0,c((0,r.jsx)(o,{color:i.purple,children:"\u2501\u2501 Bifurcated into "+n.length+" flows \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"}))),t){let g=e.flatMap((x,f)=>{let m=x.children??[];return!O.current.has(f)&&m.length>0&&(O.current.add(f),c((0,r.jsx)(o,{color:i.purple,children:" Flow "+(f+1)+": "+(n?.[f]??"")})),l?.[f]!=null&&l[f]>0&&!h.current.has(f)&&(h.current.add(f),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsxs)(o,{color:i.dim,children:[" \u25AA Generated task with ",l[f]," checkpoints"]})})))),l?.[f]!=null&&l[f]>0&&O.current.has(f)&&!h.current.has(f)&&(h.current.add(f),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsxs)(o,{color:i.dim,children:[" \u25AA Generated task with ",l[f]," checkpoints"]})}))),m});for(let x of g){let f=`${x.childId??"p"}-${x.index}-${x.objective}`;if(!!x.branchObjective){d.current.has(f)||(d.current.add(f),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(P,{step:{...x,children:void 0}})})));for(let $ of x.children??[]){let w=`child-${x.childId??"p"}-${x.index}-${$.childId??"p"}-${$.index}-${$.objective}`;d.current.has(w)||($.status==="passed"||$.status==="failed"||$.status==="stopped")&&(d.current.add(w),c((0,r.jsx)(s,{marginLeft:4,children:(0,r.jsx)(P,{step:$})})))}continue}d.current.has(f)||(x.status==="passed"||x.status==="failed"||x.status==="stopped")&&(d.current.add(f),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(P,{step:x})})))}}else for(let g of e){let x=`${g.index}-${g.objective}`,f=!!g.branchObjective;f&&!d.current.has(x)&&(d.current.add(x),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(P,{step:{...g,children:void 0}})})));for(let m of g.children??[]){let $=`child-${g.index}-${m.childId??"p"}-${m.index}-${m.objective}`;d.current.has($)||(m.status==="passed"||m.status==="failed"||m.status==="stopped")&&(d.current.add($),c((0,r.jsx)(s,{marginLeft:4,children:(0,r.jsx)(P,{step:m})})))}!f&&!d.current.has(x)&&(g.status==="passed"||g.status==="failed"||g.status==="stopped")&&(d.current.add(x),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(P,{step:{...g,children:void 0}})})))}d.current.size>p&&xe(g=>g+1)},[e,c,t,n,l]);let G=[];if(u&&!t)for(let p of e)ae.current.has(p.index)||G.push(p);else if(c&&!u)if(t)for(let p of e){let g=p.children??[],x=[];for(let f of g){let m=`${f.childId??"p"}-${f.index}-${f.objective}`,$=d.current.has(m);if(f.branchObjective){let w=(f.children??[]).filter(Q=>{let ue=`child-${f.childId??"p"}-${f.index}-${Q.childId??"p"}-${Q.index}-${Q.objective}`;return!d.current.has(ue)});(!$||w.length>0)&&x.push({...f,children:w})}else $||x.push(f)}x.length>0&&G.push({...p,children:x})}else for(let p of e){let g=`${p.index}-${p.objective}`,x=d.current.has(g),f=(p.children??[]).filter(m=>{let $=`child-${p.index}-${m.childId??"p"}-${m.index}-${m.objective}`;return!d.current.has($)});x?f.length>0&&G.push({...p,children:f}):G.push({...p,children:f})}if(!u){let p=c?G:e,g=le(p),x=ge(g,T);return(0,r.jsxs)(s,{flexDirection:"column",children:[t?c?p.length>0?(0,r.jsx)(s,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:p.map((m,$)=>(0,r.jsx)(s,{flexDirection:"column",marginTop:$>0?1:0,children:m.children&&m.children.length>0?m.children.map(w=>{if(z(w))return null;let Q=!!w.branchObjective,ue=`${w.childId??"p"}-${w.index}-${w.objective}`,Ke=d.current.has(ue);return Q?(0,r.jsxs)(s,{flexDirection:"column",children:[!Ke&&(0,r.jsx)(P,{step:{...w,children:void 0}}),(w.children??[]).filter(Z=>!z(Z)).map(Z=>(0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(P,{step:Z})},`f${$}-${w.index}-${Z.childId??"p"}-${Z.index}`))]},`f${$}-host-${w.childId??"p"}-${w.index}`):(0,r.jsx)(P,{step:w},`f${$}-${w.childId??"p"}-${w.index}`)}):m.status==="pending"&&(0,r.jsx)(o,{color:i.dim,children:" \u25CB Waiting..."})},$))}):null:(0,r.jsx)(fe,{steps:e,flows:n,cmInitCounts:l,renderStep:(m,$)=>z(m)?null:(0,r.jsx)(P,{step:m},$)}):(0,r.jsxs)(s,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:[!c&&l&&l[0]!=null&&(0,r.jsxs)(o,{color:i.dim,children:["\u25AA Generated task with ",l[0]," checkpoints"]}),p.filter(m=>!(m.status==="running"&&(!m.children||m.children.length===0))).map(m=>{let $=`${m.index}-${m.objective}`;return c&&d.current.has($)?(0,r.jsx)(s,{flexDirection:"column",children:(m.children??[]).filter(w=>!z(w)).map(w=>(0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(P,{step:w})},`${w.childId??"p"}-${w.index}`))},`branch-children-${m.index}`):(0,r.jsx)(P,{step:m},m.index)})]}),(0,r.jsx)(se,{activity:x,describe:v,describeVisible:S}),B.length>0&&(0,r.jsx)(ie,{currentStep:Y,maxSteps:a,elapsed:ce,status:N})]})}if(t){let p=le(e),g=ge(p,T);return(0,r.jsxs)(s,{flexDirection:"column",children:[(0,r.jsx)(fe,{steps:e,flows:n,cmInitCounts:l,renderStep:(x,f)=>z(x)?null:(0,r.jsx)(P,{step:x},f)}),(0,r.jsx)(se,{activity:g,describe:v,describeVisible:S}),B.length>0&&(0,r.jsx)(ie,{currentStep:Y,maxSteps:a,elapsed:ce,status:N})]})}let Ne=le(G),Ge=ge(Ne,T),Re=Fe(G);return(0,r.jsxs)(s,{flexDirection:"column",children:[Re.length>0&&(0,r.jsx)(s,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:Re.map(p=>(0,r.jsx)(P,{step:p},p.index))}),(0,r.jsx)(se,{activity:Ge,describe:v,describeVisible:S}),B.length>0&&(0,r.jsx)(ie,{currentStep:Y,maxSteps:a,elapsed:ce,status:N})]})}var W=R(k(),1);function Ae({runner:e,runKey:t,onStepCommit:n}){let l=Ie({isRunning:e.isRunning,bifurcationInfo:e.bifurcationInfo,steps:e.steps,cmInitCounts:e.cmInitCounts,replayInfo:e.replayInfo});return(0,W.jsxs)(W.Fragment,{children:[l&&(0,W.jsx)(ke,{label:l.label,hasBifurcation:l.hasBifurcation}),e.isRunning&&e.steps.length>0&&(0,W.jsx)(_e,{steps:e.steps,bifurcated:!!e.bifurcationInfo&&!e.bifurcationInfo.isSingleFlow,flows:e.bifurcationInfo?.flows,cmInitCounts:e.cmInitCounts,maxSteps:e.maxSteps,onStepCommit:n},`run-${t}`)]})}var D=R(k(),1),Ye=64;function Je(e){return e.split(`
4
4
  `).map(t=>t.replace(/^[-–•]\s*/,"").trim()).filter(t=>t.length>0)}function qe({status:e,summary:t,duration:n,steps:l,stepsPassed:a,stepsFailed:u,reason:c,creditsConsumed:v}){let S=e==="passed",T=S?i.green:i.red,d=S?"\u2713":"\u2717",L=e.toUpperCase(),O=a??(S?l:Math.max(0,l-1)),y=u??(S?0:1),h=y>0?`${l} steps (${O} passed, ${y} failed)`:`${l} steps`,b=n<60?`${n.toFixed(1)}s`:`${Math.floor(n/60)}m ${Math.round(n%60)}s`,B=Je(t);return(0,D.jsx)(s,{flexDirection:"column",marginTop:1,children:(0,D.jsxs)(s,{borderStyle:"round",borderColor:T,flexDirection:"column",paddingX:2,paddingY:1,width:Ye+6,children:[(0,D.jsxs)(s,{flexDirection:"column",children:[(0,D.jsxs)(o,{bold:!0,color:T,children:[d," ",L]}),(0,D.jsxs)(o,{color:i.dim,wrap:"wrap",children:[h," \xB7 ",b,typeof v=="number"&&v>0?` \xB7 ${parseFloat(v.toFixed(4))} credits`:""]})]}),B.length>0&&(0,D.jsx)(s,{flexDirection:"column",marginTop:1,marginLeft:1,children:B.map((F,M)=>(0,D.jsxs)(s,{marginBottom:M<B.length-1?1:0,children:[(0,D.jsx)(o,{color:i.orange,children:"\u25CF "}),(0,D.jsx)(s,{flexShrink:1,children:(0,D.jsx)(o,{wrap:"wrap",children:F})})]},M))}),c&&!S&&(0,D.jsx)(s,{marginTop:1,children:(0,D.jsxs)(o,{color:i.red,wrap:"wrap",children:["Reason: ",c]})})]})})}var j=R(k(),1);function Me({message:e,code:t,remediation:n,docsUrl:l}){return(0,j.jsx)(ve,{title:"Error",variant:"error",children:(0,j.jsxs)(s,{flexDirection:"column",paddingY:1,children:[(0,j.jsxs)(o,{color:i.red,bold:!0,children:[" \u2717 ",e]}),t&&(0,j.jsxs)(s,{marginTop:0,marginLeft:5,children:[(0,j.jsx)(o,{color:i.muted,children:"Code: "}),(0,j.jsx)(o,{color:i.dim,children:t})]}),n&&(0,j.jsxs)(s,{flexDirection:"column",marginTop:1,marginLeft:5,children:[(0,j.jsx)(o,{color:i.green,bold:!0,children:"Fix:"}),(0,j.jsxs)(o,{color:i.orange,children:["$ ",n]})]}),l&&(0,j.jsxs)(s,{marginTop:1,marginLeft:5,children:[(0,j.jsx)(o,{color:i.muted,children:"Docs: "}),(0,j.jsx)(o,{color:i.orange,underline:!0,children:l})]})]})})}var E=R(k(),1);function un(e){let{exit:t}=Te(),{append:n}=ye(),l=(0,A.useRef)(!1);(0,A.useEffect)(()=>{l.current||(l.current=!0,n((0,E.jsx)(s,{flexDirection:"column",marginBottom:1,children:(0,E.jsxs)(s,{borderStyle:"round",borderColor:"#dc4e08",paddingX:2,children:[(0,E.jsx)(o,{color:"#ff9500",bold:!0,children:"KaneAI CLI"}),(0,E.jsx)(o,{color:i.dim,children:" \u2502 "}),(0,E.jsx)(o,{color:i.orange,children:e.topBanner.model}),(0,E.jsx)(o,{color:i.dim,children:" \u2502 "}),(0,E.jsx)(o,{color:i.dim,children:e.topBanner.auth})]})})),n((0,E.jsx)(Qe,{data:e.globalConfig})),e.priorAttemptRollup&&n((0,E.jsx)(o,{color:i.dim,children:` \u21B3 replayed ${e.priorAttemptRollup.startIdx}..${e.priorAttemptRollup.endIdx-1} (${e.priorAttemptRollup.count} steps, from prior attempt)`})))},[]);let a=(0,A.useRef)(null),u=(0,A.useCallback)(async y=>{let h=await e.getNextStep(y);return h?(a.current=h,h.config):(a.current=null,null)},[e]),c=(0,A.useCallback)((y,h)=>{let b=a.current;if(!b)return;let B=b.mode==="replay"?"cyan":"#dc4e08",F=b.modeReason?` (${b.modeReason})`:"",M=b.perStepOverrides?Object.entries(b.perStepOverrides):[];n((0,E.jsxs)(s,{flexDirection:"column",marginBottom:0,children:[(0,E.jsxs)(o,{children:[(0,E.jsxs)(o,{color:i.dim,children:[b.banner.stepLabel," "]}),(0,E.jsxs)(o,{color:B,children:["[",b.mode,"]"]}),(0,E.jsx)(o,{color:i.dim,children:F})]}),(0,E.jsx)(o,{color:i.dim,children:b.banner.objective}),M.length>0&&(0,E.jsxs)(o,{color:i.dim,children:["overrides: ",M.map(([X,Y])=>`${X}=${Y}`).join(", ")]})]}))},[n]),v=(0,A.useRef)(0),S=(0,A.useRef)(!1),T=(0,A.useCallback)((y,h)=>(y.hadError?n((0,E.jsx)(Me,{message:y.reason??"Runner error",code:"RUNNER_ERROR"})):n((0,E.jsx)(s,{flexDirection:"column",marginBottom:1,children:(0,E.jsx)(qe,{status:y.status,summary:y.runEnd?.summary??"",duration:y.runEnd?.duration??0,steps:y.stepsTotal,stepsPassed:y.stepsPassed,stepsFailed:y.stepsFailed,reason:y.runEnd?.reason,creditsConsumed:y.runEnd?.credits_consumed})})),e.onStepEnd?.(y,h)??!0),[n,e]),d=we({getNextConfig:u,onStepStart:c,onStepEnd:T,onAllComplete:()=>{e.onAllComplete(),e.exitOnComplete!==!1&&setImmediate(()=>t())},screenshotDispatcher:e.screenshotDispatcher,stepLogger:e.stepLogger,onReasoning:e.onReasoning,onStepComplete:e.onStepComplete,spawnOpts:e.spawnOpts}),L=250,O=5e3;return Se((y,h)=>{if(h.ctrl&&y==="c"){let b=Date.now(),B=b-v.current;if(B<L)return;S.current&&B<O?(d.cancel(),e.onCancel?.(),e.exitOnComplete!==!1&&setImmediate(()=>t())):(S.current=!0,n((0,E.jsx)(o,{color:"yellow",children:"press Ctrl+C again to cancel run"}))),v.current=b}}),(0,E.jsx)(s,{flexDirection:"column",children:d.phase!=="done"&&(0,E.jsx)(Ae,{runner:d.runner,runKey:d.currentStepIndex,onStepCommit:n})})}function Qe({data:e}){return(0,E.jsx)(Be,{title:"test.md run",titleColor:"#ff9500",borderColor:i.dim,rows:[{label:"source",value:e.source},{label:"steps",value:`${e.steps.total} (${e.steps.replay} replay, ${e.steps.author} author per walker)`},{label:"model",value:e.model},{label:"viewport",value:`${e.viewport.width} x ${e.viewport.height}`},{label:"chrome",value:e.chrome},{label:"session",value:e.session},{label:"variables",value:`${e.variables.count} (${e.variables.secrets} secret)`},{label:"flags",value:e.flags.length>0?e.flags.join(" "):"(none)"}]})}export{_e as a,ke as b,Ie as c,de as d,qe as e,Me as f,un as g};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as B,c as S,d as T}from"./chunk-K2UEVCIJ.js";import{c as g}from"./chunk-RFHMDQXZ.js";import{a as E}from"./chunk-AQWTK6IN.js";import{y as n}from"./chunk-33GXXC2L.js";import{a as h}from"./chunk-HCBYKLMW.js";import{a as i,b as c,c as w,i as x}from"./chunk-C44QQJR4.js";import{a as L}from"./chunk-6YGTRKDT.js";import{e as u}from"./chunk-UR6MHSHU.js";var l=u(L(),1);var r=u(h(),1);function y(e){return new Map(e.map((o,s)=>[`${s}-${o.label}`,o.packPath]))}async function H(e){let o=e.deps?.viewerBase??S(e.env),s=e.deps?.startServer??B,a=e.deps?.openUrl??(m=>g(m).then(()=>{})),t=y(e.rows),d;try{d=await s({packs:t,allowedOrigins:[new URL(o).origin]});let m=d,D=async p=>{let v=[...t.keys()][p];await a(T(m.urlFor(v),o))};if(e.deps?.hold){await e.deps.hold();return}await new Promise(p=>{let v=w(l.default.createElement(P,{rows:e.rows,onOpen:D,onDone:()=>{v.unmount(),p()}}),{stdout:process.stderr,exitOnCtrlC:!1})})}finally{await d?.close()}}function I(e){return e==="passed"?n.green:e==="failed"||e==="broken"||e==="cancelled"?n.red:n.dim}var b=40,R=9,k=20;function f(e,o){return e.length>o?e.slice(0,o-1)+"\u2026":e.padEnd(o)}function O({row:e,selected:o}){let s=e.testId??e.commitId??"";return(0,r.jsxs)(i,{children:[(0,r.jsx)(i,{width:2,flexShrink:0,children:(0,r.jsx)(c,{color:n.orange,children:o?"\u25B8":" "})}),(0,r.jsx)(i,{width:2,flexShrink:0,children:(0,r.jsx)(c,{color:e.kind==="execution"?n.orange:n.muted,children:e.kind==="execution"?"\u25CF":"\u25CB"})}),(0,r.jsx)(i,{width:b,flexShrink:0,children:(0,r.jsx)(c,{color:o?n.orange:void 0,bold:o,wrap:"truncate-end",children:f(e.label,b)})}),(0,r.jsx)(i,{width:R,flexShrink:0,children:(0,r.jsx)(c,{color:I(e.status),bold:o,wrap:"truncate-end",children:f(e.status,R)})}),(0,r.jsx)(i,{width:k,flexShrink:0,children:(0,r.jsx)(c,{color:n.dim,wrap:"truncate-end",children:f(s,k)})})]})}function P(e){let[o,s]=(0,l.useState)(0);return x((a,t)=>{t.upArrow?s(d=>Math.max(0,d-1)):t.downArrow?s(d=>Math.min(e.rows.length-1,d+1)):t.return||a==="o"?e.onOpen(o):(a==="q"||t.escape)&&e.onDone()}),(0,r.jsx)(E,{title:"Evidence",borderColor:n.muted,children:(0,r.jsxs)(i,{flexDirection:"column",children:[e.rows.map((a,t)=>(0,r.jsx)(O,{row:a,selected:t===o},t)),(0,r.jsx)(i,{marginTop:1,children:(0,r.jsx)(c,{color:n.dim,children:"\u2191/\u2193 move \xB7 enter/o open \xB7 q quit"})})]})})}export{y as a,H as b};
2
+ import{b as B,c as S,d as T}from"./chunk-VNFCX2SH.js";import{c as g}from"./chunk-RFHMDQXZ.js";import{a as E}from"./chunk-ARG56PJG.js";import{y as n}from"./chunk-B2ZGG7WM.js";import{a as h}from"./chunk-HCBYKLMW.js";import{a as i,b as c,c as w,i as x}from"./chunk-C44QQJR4.js";import{a as L}from"./chunk-6YGTRKDT.js";import{e as u}from"./chunk-UR6MHSHU.js";var l=u(L(),1);var r=u(h(),1);function y(e){return new Map(e.map((o,s)=>[`${s}-${o.label}`,o.packPath]))}async function H(e){let o=e.deps?.viewerBase??S(e.env),s=e.deps?.startServer??B,a=e.deps?.openUrl??(m=>g(m).then(()=>{})),t=y(e.rows),d;try{d=await s({packs:t,allowedOrigins:[new URL(o).origin]});let m=d,D=async p=>{let v=[...t.keys()][p];await a(T(m.urlFor(v),o))};if(e.deps?.hold){await e.deps.hold();return}await new Promise(p=>{let v=w(l.default.createElement(P,{rows:e.rows,onOpen:D,onDone:()=>{v.unmount(),p()}}),{stdout:process.stderr,exitOnCtrlC:!1})})}finally{await d?.close()}}function I(e){return e==="passed"?n.green:e==="failed"||e==="broken"||e==="cancelled"?n.red:n.dim}var b=40,R=9,k=20;function f(e,o){return e.length>o?e.slice(0,o-1)+"\u2026":e.padEnd(o)}function O({row:e,selected:o}){let s=e.testId??e.commitId??"";return(0,r.jsxs)(i,{children:[(0,r.jsx)(i,{width:2,flexShrink:0,children:(0,r.jsx)(c,{color:n.orange,children:o?"\u25B8":" "})}),(0,r.jsx)(i,{width:2,flexShrink:0,children:(0,r.jsx)(c,{color:e.kind==="execution"?n.orange:n.muted,children:e.kind==="execution"?"\u25CF":"\u25CB"})}),(0,r.jsx)(i,{width:b,flexShrink:0,children:(0,r.jsx)(c,{color:o?n.orange:void 0,bold:o,wrap:"truncate-end",children:f(e.label,b)})}),(0,r.jsx)(i,{width:R,flexShrink:0,children:(0,r.jsx)(c,{color:I(e.status),bold:o,wrap:"truncate-end",children:f(e.status,R)})}),(0,r.jsx)(i,{width:k,flexShrink:0,children:(0,r.jsx)(c,{color:n.dim,wrap:"truncate-end",children:f(s,k)})})]})}function P(e){let[o,s]=(0,l.useState)(0);return x((a,t)=>{t.upArrow?s(d=>Math.max(0,d-1)):t.downArrow?s(d=>Math.min(e.rows.length-1,d+1)):t.return||a==="o"?e.onOpen(o):(a==="q"||t.escape)&&e.onDone()}),(0,r.jsx)(E,{title:"Evidence",borderColor:n.muted,children:(0,r.jsxs)(i,{flexDirection:"column",children:[e.rows.map((a,t)=>(0,r.jsx)(O,{row:a,selected:t===o},t)),(0,r.jsx)(i,{marginTop:1,children:(0,r.jsx)(c,{color:n.dim,children:"\u2191/\u2193 move \xB7 enter/o open \xB7 q quit"})})]})})}export{y as a,H as b};
@@ -0,0 +1,4 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a as Te}from"./chunk-JQW2QFSX.js";import{H as ge,M as re,T as Oe,X as we,c as ne,d as K,f as fe,m as te,p as xe,x as Ie}from"./chunk-3N6IAVD5.js";import{d as se,e as O,f as ie,g as ae,h as le}from"./chunk-AKX4VRRR.js";function Le(t,s){let r=t.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");if(r.length>60){let c=r.lastIndexOf("-",60);r=(c>0?r.slice(0,c):r.slice(0,60)).replace(/-+$/g,"")}if(!pe.test(r))return null;let e=r;for(let c=2;s(e);c++)e=`${r}-${c}`;return pe.test(e)?e:null}var Ge={source:"src",usecase:"uc",scenario:"sc",ac:"ac",test:"t",gap:"gap",stylenote:"sty"};function rt(t,s,r){let e=Ge[t];return Le(e?`${e} ${s}`:s,r)}var Ue={usecase:"uc",scenario:"sc",ac:"ac",test:"t",gap:"gap",stylenote:"sty"},ke=/^(uc|sc|ac|t|gap|sty)-\d+$/i;function De(t,s,r){let e=Ue[t];if(!e)return null;let c=new RegExp(`^${e}-(\\d+)$`),l=0;for(let d of r){let a=c.exec(d);if(!a)continue;let n=Number(a[1]);Number.isSafeInteger(n)&&n>l&&(l=n)}let o=l+1;for(;s(`${e}-${o}`);)o+=1;return`${e}-${o}`}var Fe=/^L([1-9]\d*)-L([1-9]\d*)$/,je=/^img#(p[1-9]\d*-[1-9]\d*|i[1-9]\d*)$/;function he(t){if(t==="img#whole")return{kind:"img-whole"};let s=je.exec(t);if(s)return{kind:"img-part",ref:s[1]};let r=Fe.exec(t);return r?{kind:"lines",a:parseInt(r[1],10),b:parseInt(r[2],10)}:null}function He(t,s){let r=/^L(\d+)-L(\d+)$/.exec(s);if(!r)return null;let e=parseInt(r[1],10),c=parseInt(r[2],10),l=t.split(`
3
+ `);return e<1||c<e||c>l.length?null:l.slice(e-1,c).map(o=>o.replace(/^\d+\| /,"")).join(`
4
+ `)}function Ae(t,s,r){let e=he(s.anchor);if(t.format==="image")return e?.kind==="img-whole"?[]:[{code:"CITE_ANCHOR_INVALID",detail:`image cites are anchor-only (img#whole), got ${s.anchor}`}];if(e?.kind==="img-part")return new Set((t.images??[]).map(o=>o.ref)).has(e.ref)?[]:[{code:"CITE_ANCHOR_INVALID",detail:`anchor ${s.anchor} names no embedded image of this source version`}];if(!s.anchor||s.quote===void 0||s.quote==="")return[{code:"MISSING_CITE",detail:"text-kind cites need anchor+quote"}];let c=r!==null?He(r,s.anchor):null;return c===null?[{code:"BAD_ANCHOR",detail:`anchor ${s.anchor} does not resolve in the source`}]:c.includes(s.quote)?[]:[{code:"QUOTE_MISMATCH",detail:`quote is not verbatim within ${s.anchor}`}]}import{existsSync as qe,readFileSync as Ke}from"fs";function pt(t){return We(t,we(t))}function We(t,s,r){let e=new Map(Object.entries(s.heads)),c=new Map(Object.entries(s.trust)),l=new Map(Object.entries(s.nodeLabel)),o=new Map(Object.entries(s.superseded)),d=new Map(Object.entries(s.names)),a=new Map(Object.entries(s.archivedReason)),n=new Set(s.appliedEvents),E=new Map(Object.entries(s.conv)),f=p=>s.media[p]??{format:"text",media_type:"text/plain",anchors_supported:["L-L"]},_=new Map;for(let[p,m]of d)_.set(m,p);let g=new Map,y=p=>{if(g.has(p))return g.get(p);if(!l.has(p))return g.set(p,null),null;let m=r?.get(p);if(m)return g.set(p,m),m;let C=Oe(t,p);if(!qe(C))throw new xe(`derived node file missing for ${p} \u2014 run kane-cli context rebuild`);let R=JSON.parse(Ke(C,"utf8"));return g.set(p,R),R},v=p=>{let m=p,C=new Set;for(;o.has(m)&&!C.has(m);){C.add(m);let R=o.get(m);if(typeof R!="string")break;m=R}return m},w=null,N=p=>{let m=_.get(p);if(m!==void 0)return m;if(w===null){w=new Map;for(let[F,A]of o)typeof A=="string"&&w.set(A,F)}let C=new Set,R=p;for(;!C.has(R);){C.add(R);let F=w.get(R);if(F===void 0)return null;let A=_.get(F);if(A!==void 0)return A;R=F}return null},T=p=>{ke.test(p)&&(p=p.toLowerCase());let m=e.get(p),C=l.has(p)?p:d.get(p)??(typeof m=="string"?m:void 0);if(C===void 0||!l.has(C))return null;let R=v(C);return{cid:C,tip:R,superseded:o.has(C)||o.has(R)}},L=new Map;for(let p of Object.values(s.forward))for(let m of p){let C=L.get(m.dst);C?C.push(m):L.set(m.dst,[m])}let P=p=>(p??[]).filter(m=>!o.has(m.ecid)),W=p=>P(L.get(p)),G=p=>W(p).filter(m=>m.type===O.DERIVES),Q=p=>P(s.forward[p]).some(m=>ae(m.type)?.pin?.comparesTo==="dst_tip"&&o.has(m.dst)),oe=p=>{if(o.has(p))return"superseded";let m=G(p);if(m.length===0)return Q(p)?"stale":"fresh";let C=new Map;for(let A of m)C.set(A.props.source_id,A);let R=!1,F=!1;for(let[A,D]of C){let M=e.get(A);if(M!=null&&(R=!0,M!==D.props.source_cid)){let ce=E.get(A)?.chain;(!ce||!ce.includes(D.props.source_cid))&&(F=!0)}}return R?F||Q(p)?"stale":"fresh":"orphaned"};return{heads:e,trust:c,nodeLabel:l,superseded:o,names:d,nameOf:_,archivedReason:a,appliedEvents:n,convChains:E,mediaOf:f,extractedSourceCids:new Set(s.extracted),extractionCompleteness:new Map(Object.entries(s.completeness??{}).map(([p,{seq:m,...C}])=>[p,C])),designOf:new Map(Object.entries(s.design_of??{})),designGenerationOf:new Map(Object.entries(s.design_generation??{})),latestHash:s.applied.hash,lastSeq:s.applied.seq,hasNode:p=>l.has(p),getNode:y,byLabel:p=>[...l.entries()].filter(([,m])=>m===p).map(([m])=>({cid:m,content:y(m)?.content??{}})),edgesFrom:p=>P(s.forward[p]),edgesInto:W,derivesInto:G,resolve:T,tipOf:v,displayNameOf:N,stale:oe,staleList:()=>[...l.keys()].map(p=>({cid:p,state:oe(p)})).filter(p=>p.state!=="fresh"),execHistory:p=>{let m=T(p);if(!m)return[];let C=v(m.cid),R=new Set([C]),F=!0;for(;F;){F=!1;for(let[D,M]of o)M!==null&&R.has(M)&&!R.has(D)&&(R.add(D),F=!0)}let A=[];for(let D of Object.entries(s.exec??{}))R.has(D[0])&&A.push(...D[1]);return A.sort((D,M)=>D.started_at<M.started_at?-1:1)},retractedEdgesTouching:p=>{let m=new Set([v(p),p]),C=!0;for(;C;){C=!1;for(let[D,M]of o)typeof M=="string"&&m.has(M)&&!m.has(D)&&(m.add(D),C=!0)}let R=s.edgeRetractions??{},F=[],A=new Set;for(let D of m)for(let M of[...s.forward[D]??[],...L.get(D)??[]]){let ce=R[M.ecid];!ce||A.has(M.ecid)||(A.add(M.ecid),F.push({...M,retraction:ce}))}return F}}}function ft(t,s){if(t.stale(s)!=="stale")return!1;let r=new Map;for(let e of t.derivesInto(s))r.set(e.props.source_id,e);for(let[e,c]of r){let l=t.heads.get(e);if(l==null||l===c.props.source_cid)continue;let o=t.convChains.get(e)?.chain;if(!o||!o.includes(c.props.source_cid))return!0}for(let e of t.edgesFrom(s)){if(ae(e.type)?.pin?.comparesTo!=="dst_tip"||!t.superseded.has(e.dst))continue;let c=t.tipOf(e.dst);if(t.superseded.has(c)||t.nodeLabel.get(c)==="usecase")return!0}return!1}function me(t,s){let r=new Map;for(let[o,d]of t.superseded)typeof d=="string"&&d!==o&&r.set(d,[...r.get(d)??[],o]);let e=[],c=[s],l=new Set;for(;c.length>0;){let o=c.pop();l.has(o)||(l.add(o),e.push(o),c.push(...r.get(o)??[]))}return e}function Be(t,s){return(t.extraction_claims??[]).some(r=>r.source_id===s&&r.completeness==="complete")}function Je(t,s){let r=new Set;for(let e of me(t,s))for(let c of t.derivesInto(e))r.add(c.props?.source_id??"conversation");return r}function ye(t,s){let r=[],e=[],c=t.archived??[];if(c.length===0)return{valid:r,errors:e};let l=new Set([...t.source?[t.source.source_id]:[],...(t.sources??[]).map(d=>d.source_id)]),o=new Set;for(let d of t.use_cases){if(!d.matches_existing)continue;let a=s.resolve(d.matches_existing.cid);a&&o.add(s.tipOf(a.cid))}for(let d of c){let a=`archived[${d.target}]`,n=s.resolve(d.target),E=n?s.tipOf(n.cid):null;if(!E||(s.trust.get(E)??null)==="archived"){e.push({code:"ARCHIVE_TARGET_UNKNOWN",detail:`${a}: target does not resolve to an existing, live item`});continue}let f=Je(s,E);if(!f.has(d.basis)){e.push({code:"ARCHIVE_FOREIGN_PROVENANCE",detail:`${a}: its provenance does not include ${d.basis} \u2014 an archive claim must come from a source that evidences the item`});continue}if(!l.has(d.basis)){e.push({code:"ARCHIVE_WITHOUT_COMPLETE_CLAIM",detail:`${a}: ${d.basis} was not read by this extraction \u2014 a completeness claim only counts for a source this run actually read`});continue}if(!Be(t,d.basis)){e.push({code:"ARCHIVE_WITHOUT_COMPLETE_CLAIM",detail:`${a}: archiving needs an EXPLICIT complete extraction claim for ${d.basis} (the omitted-claims default does not count) \u2014 add extraction_claims`});continue}if(o.has(E)){e.push({code:"ARCHIVE_TARGET_MATCHED",detail:`${a}: this proposal also matches the target via matches_existing \u2014 a matched item cannot be archived by the same extraction; propose the change as an update instead`});continue}let _=[...f].filter(g=>g!==d.basis);if(_.length>0){e.push({code:"ARCHIVE_OTHER_LIVE_EVIDENCE",detail:`${a}: still evidenced by ${_.join(", ")} \u2014 an item another live source evidences is never archived from here`});continue}r.push({op:d,cid:E})}return{valid:r,errors:e}}function Ce(t,s,r){return t.superseded.has(r)}function Me(t){let{graph:s,oldTip:r,newCid:e,newLabel:c,by:l}=t,o=[],d=[],a=[],n=[],E=new Set;for(let f of s.edgesFrom(r)){if(f.type===O.DERIVES||t.skipEcids?.has(f.ecid))continue;d.push({kind:"edge",ecid:f.ecid,reason:t.reason,by:l}),E.add(f.ecid);let _=t.dstRedirect?.get(f.dst)??f.dst,g=s.nodeLabel.get(f.dst)??"(unknown)",y=le(f.type,c,g,f.props);if(y.length>0){a.push(`rebless ${f.type} \u2192 ${f.dst}: ${y.map(N=>N.detail).join("; ")}`);continue}let v=Te(s,{type:f.type,src:e,dst:_},{pending:n,retracted:E},`rebless ${f.type}`);if(v){a.push(v.detail);continue}let w=K(f.type,e,_,f.props);if(s.superseded.has(w)){a.push(`rebless ${f.type} \u2192 ${_}: the re-derived edge (${w}) was retracted \u2014 retraction is terminal, the successor cannot revive it`);continue}o.push({ecid:w,type:f.type,src:e,dst:_,props:f.props}),n.push({src:e,dst:_,type:f.type})}return{edges:o,supersessions:d,errors:a}}var pe=/^[a-z0-9][a-z0-9-]{1,63}$/;function Pe(t,s,r,e){if(!s)return{error:{code:"SUPERSEDE_TARGET_MISSING",detail:"supersede verdict needs a target (slug or cid)"}};let c=t.resolve(s);return c?c.superseded||e.has(c.cid)?{error:{code:"ALREADY_SUPERSEDED",detail:`${s} is already superseded (tip: ${c.tip})`}}:c.cid===r?{error:{code:"SELF_SUPERSEDE",detail:"a node cannot supersede itself"}}:{targetCid:c.cid}:{error:{code:"UNKNOWN_SUPERSEDE_TARGET",detail:`${s} names nothing in the graph`}}}function Ye(t,s,r,e,c=[]){if(!ae(s)?.acyclic)return null;if(r===e)return{code:"EDGE_CYCLE",detail:`${s} ${r} \u2192 itself`};let o=n=>[...t.edgesFrom(n).filter(E=>E.type===s).map(E=>E.dst),...c.filter(E=>E.type===s&&E.src===n).map(E=>E.dst)],d=new Set,a=[e];for(;a.length>0;){let n=a.pop();if(n===r)return{code:"EDGE_CYCLE",detail:`${s} ${r} \u2192 ${e} closes a cycle`};d.has(n)||(d.add(n),a.push(...o(n)))}return null}function kt(t,s,r,e){let l=ae(s)?.cardinality;if(l!=="one-live-per-src"&&l!=="one-live-per-src-and-dst")return null;let o=t.edgesFrom(r).filter(d=>d.type===s&&!t.superseded.has(d.dst));if(o.length>0)return{code:"CARDINALITY_VIOLATION",detail:`${s} from ${r} already has a live edge (${o[0].ecid}) \u2014 supersede it first`};if(l==="one-live-per-src-and-dst"&&e!==void 0){let d=t.edgesInto(e).filter(a=>a.type===s&&!t.superseded.has(a.src));if(d.length>0)return{code:"CARDINALITY_VIOLATION",detail:`${s} onto ${e} already has a live edge (${d[0].ecid}) \u2014 strict 1:1, supersede it first`}}return null}var $e=new Set(["high","med","low"]),_e=t=>t.cites&&t.cites.length>0?t.cites:[t.cite];function Ee(t){let s=0;for(let r of t)typeof r=="object"&&r!==null&&"op"in r&&s++;return s===0?"flat":s===t.length?"ops":"mixed"}var Qe=/^c[1-9][0-9]*$/;function Ve(t,s,r,e){let c=new Map,l=[],o=[];for(let[a,n]of s.entries()){let E=`${t}.updated.criteria[${a}]`;if(n.op==="keep"||n.op==="remove"){if(!Qe.test(n.ref??"")){e.push({code:"CRITERIA_REF_UNKNOWN",detail:`${E}: ref ${JSON.stringify(n.ref)} is not a c<N> criterion index`});continue}if(c.has(n.ref)){e.push({code:"CRITERIA_REF_DUPLICATE",detail:`${E}: ${n.ref} is already named by another op \u2014 every prior criterion appears in exactly one keep or remove`});continue}c.set(n.ref,n);let f=Number.parseInt(n.ref.slice(1),10);if(f>r.length){e.push({code:"CRITERIA_REF_UNKNOWN",detail:`${E}: ${n.ref} \u2014 the live target has ${r.length} criteria`});continue}if(r[f-1]!==n.text){e.push({code:"CRITERIA_REF_MISMATCH",detail:`${E}: ${n.ref} echo mismatch \u2014 the live target's criterion ${f} reads ${JSON.stringify(r[f-1])}, the op echoed ${JSON.stringify(n.text)} \u2014 re-read the node and re-emit`});continue}n.op==="remove"&&(l.push(n.text),(!n.reason||!n.reason.trim())&&e.push({code:"EMPTY_REASON",detail:`${E}: a remove op carries its reason`}))}else!n.text||!n.text.trim()?e.push({code:"EMPTY_CRITERION",detail:`${E}: set text is empty`}):o.push(n.text)}let d=[];for(let a=1;a<=r.length;a++)c.has(`c${a}`)||d.push(`c${a}`);d.length>0&&e.push({code:"CRITERIA_PARTITION_INCOMPLETE",detail:`${t}: prior criteria ${d.join(", ")} named by no keep/remove op \u2014 every prior criterion must be kept or removed (with a reason)`});for(let a of l)o.includes(a)&&e.push({code:"CRITERIA_OP_CONFLICT",detail:`${t}: ${JSON.stringify(a)} is removed AND re-set in the same update \u2014 drop one of the two ops`})}function Dt(t,s,r){let e=[],c=t.sources??[t.source],l=new Map(c.map(n=>[n.source_id,n.source_cid])),o=new Map;if(typeof s=="string")o.set(t.source.source_id,{media:r.mediaOf(t.source.source_cid),numberedText:s});else for(let[n,E]of s)o.set(n,E);for(let n of c)r.hasNode(n.source_cid)||e.push({code:"MISSING_SOURCE_NODE",detail:`source ${n.source_id} (${n.source_cid}) is not a committed node \u2014 ingest it first`});let d=(n,E)=>{let f=E.source_id??t.source.source_id;if(!l.has(f)){e.push({code:"CITE_SOURCE_UNKNOWN",detail:`${n}: cite source ${JSON.stringify(f)} is not in read_basis`});return}let _=o.get(f);if(!_){e.push({code:"MISSING_SOURCE_NODE",detail:`${n}: no citable text available for source ${f}`});return}for(let g of Ae(_.media,E,_.numberedText))e.push({code:g.code,detail:`${n}: ${g.detail}`})},a=new Set;for(let n of t.use_cases){if(a.has(n.temp_ref)&&e.push({code:"DUP_TEMP_REF",detail:`duplicate temp_ref ${n.temp_ref}`}),a.add(n.temp_ref),(!n.title||!n.title.trim())&&e.push({code:"EMPTY_TITLE",detail:`${n.temp_ref}: title is empty`}),$e.has(n.risk)||e.push({code:"BAD_RISK",detail:`${n.temp_ref}: risk ${JSON.stringify(n.risk)} not in high|med|low`}),!n.cite||!n.cite.anchor)e.push({code:"MISSING_CITE",detail:`${n.temp_ref}: every derived use-case must carry a cite`});else for(let f of _e(n))d(n.temp_ref,f);n.matches_existing&&!r.hasNode(n.matches_existing.cid)&&e.push({code:"UNKNOWN_MATCH",detail:`${n.temp_ref}: matches_existing ${n.matches_existing.cid} is not in the graph`});for(let[f,_]of(n.criteria??[]).entries())(!_.text||!_.text.trim())&&e.push({code:"EMPTY_CRITERION",detail:`${n.temp_ref}.criteria[${f}]: text is empty`}),!_.cite||!_.cite.anchor?e.push({code:"MISSING_CITE",detail:`${n.temp_ref}.criteria[${f}]: every criterion carries its own cite`}):d(`${n.temp_ref}.criteria[${f}]`,_.cite);let E=n.updated?.criteria??[];if(E.length>0){let f=Ee(E);if(f==="mixed")e.push({code:"CRITERIA_SHAPE_MIXED",detail:`${n.temp_ref}.updated.criteria mixes op-shaped (keep/set/remove) and {text, cite} entries \u2014 emit ONE shape for the whole array`});else if(f==="ops"){let _=E,g=n.matches_existing?Ze(r,n.matches_existing.cid):null;if(!g)e.push({code:"CRITERIA_REF_UNKNOWN",detail:`${n.temp_ref}: op-union criteria address a prior version \u2014 they need a resolvable matches_existing target`});else{let y=r.getNode(g.cid)?.content.criteria??[];Ve(n.temp_ref,_,y,e)}for(let[y,v]of _.entries())v.op==="set"&&(!v.cite||!v.cite.anchor?e.push({code:"MISSING_CITE",detail:`${n.temp_ref}.updated.criteria[${y}]: a set op carries the proposing source's cite`}):d(`${n.temp_ref}.updated.criteria[${y}]`,v.cite))}else for(let[_,g]of E.entries())(!g.text||!g.text.trim())&&e.push({code:"EMPTY_CRITERION",detail:`${n.temp_ref}.updated.criteria[${_}]: text is empty`}),!g.cite||!g.cite.anchor?e.push({code:"MISSING_CITE",detail:`${n.temp_ref}.updated.criteria[${_}]: every updated criterion carries its own cite`}):d(`${n.temp_ref}.updated.criteria[${_}]`,g.cite)}}return e.push(...ye(t,r).errors),e}function Xe(t,s,r){return`${t}:${s}:${r}`}function ze(t,s,r,e){let c=`${s}:${r}:`,l=0;for(let o of t.appliedEvents){if(!o.startsWith(c))continue;let d=o.slice(c.length);if(!/^\d+$/.test(d))continue;let a=Number.parseInt(d,10);a>l&&(l=a)}return Array.from({length:e},(o,d)=>Xe(s,r,l+1+d))}function Ze(t,s){let r=t.resolve(s);if(r===null)return null;let e=r.cid;if(t.superseded.has(e)){let c=t.tipOf(e);return t.superseded.has(c)?null:{cid:c,redirected:!0}}return{cid:e,redirected:!1}}function At(t){let{contextDir:s,graph:r,proposal:e,proposalId:c,verdicts:l,by:o,allowStaleBasis:d,extractorVersion:a,autoName:n}=t,E=ge(s);if(!d&&e.read_basis!==E)return{record:null,errors:[{code:"STALE_BASIS",detail:`proposal read_basis ${String(e.read_basis)} != latest ${String(E)}`}]};for(let i of e.sources??[e.source])if(!r.hasNode(i.source_cid))return{record:null,errors:[{code:"MISSING_SOURCE_NODE",detail:`source ${i.source_id} (${i.source_cid}) is not a committed node \u2014 ingest it first`}]};let f=new Map((e.sources??[e.source]).map(i=>[i.source_id,i.source_cid])),_={supersedeTarget:{},matches_existing:{},conflicts_with:{},depends_on_hint:{},read_basis_heads:Object.fromEntries(f)},g=[],y=[],v=new Map,w=[],N=r.mediaOf(e.source.source_cid),T=new Set,L=[],P=[],W=[],G=[];for(let i of ye(e,r).valid)G.push({id:i.cid,kind:"pending_archive",resolution:"pending",edit:null,reason:i.op.reason,by:o});let Q=[],oe=[],p=new Set,m=new Set,C=(i,h,j)=>{let Y=Pe(r,h.supersedeTarget,j,p);if("error"in Y){g.push({code:Y.error.code,detail:`${i}: ${Y.error.detail}`});return}p.add(Y.targetCid),_.supersedeTarget[i]=Y.targetCid,Q.push({kind:"node",old:Y.targetCid,new:j,reason:h.reason??`superseded via review by ${o.id}`,by:o})};for(let i of e.use_cases){let h=l.get(i.temp_ref)??{resolution:"skipped"};T.has(i.temp_ref)&&g.push({code:"DUP_TEMP_REF",detail:`duplicate temp_ref ${i.temp_ref}`}),T.add(i.temp_ref),i.conflicts_with&&(_.conflicts_with[i.temp_ref]=i.conflicts_with.map(u=>r.resolve(u)?.cid??null)),(!i.title||!i.title.trim())&&g.push({code:"EMPTY_TITLE",detail:`${i.temp_ref}: title is empty`}),$e.has(i.risk)||g.push({code:"BAD_RISK",detail:`${i.temp_ref}: risk ${JSON.stringify(i.risk)} not in high|med|low`});let j=he(i.cite?.anchor??""),Y=i.cite?.source_id!==void 0&&f.has(i.cite.source_id)?r.mediaOf(f.get(i.cite.source_id)):N;if(Y.format==="image"){if(j?.kind!=="img-whole"){g.push({code:i.cite?.anchor?"CITE_ANCHOR_INVALID":"MISSING_CITE",detail:`${i.temp_ref}: image cites are anchor-only (img#whole)`});continue}}else if(j?.kind==="img-part"){if(!(Y.images??[]).some(S=>S.ref===j.ref)){g.push({code:"CITE_ANCHOR_INVALID",detail:`${i.temp_ref}: anchor ${i.cite?.anchor} names no embedded image of this source version`});continue}}else if(!i.cite||!i.cite.anchor||!i.cite.quote){g.push({code:"MISSING_CITE",detail:`${i.temp_ref}: every derived use-case must cite anchor+quote`});continue}h.resolution==="edited"&&h.edit&&(h.edit.title!==void 0&&!h.edit.title.trim()&&g.push({code:"EMPTY_TITLE",detail:`${i.temp_ref}: edited title is empty`}),h.edit.risk!==void 0&&!$e.has(h.edit.risk)&&g.push({code:"BAD_RISK",detail:`${i.temp_ref}: edited risk ${JSON.stringify(h.edit.risk)} invalid`}));let ve=fe({title:h.edit?.title??i.title,description:i.description,summary:h.edit?.summary??i.summary,actors:i.actors,value:i.value,risk:h.edit?.risk??i.risk,...i.criteria&&i.criteria.length>0?{criteria:i.criteria.map(u=>u.text)}:{}}),b=ne("usecase",ve),Se=i.cite.source_id??e.source.source_id,Ne=f.get(Se);if(i.cite.source_id!==void 0&&Ne===void 0){g.push({code:"CITE_SOURCE_UNKNOWN",detail:`${i.temp_ref}: cite source ${JSON.stringify(Se)} is not in read_basis`});continue}let ee={source_id:Se,source_cid:Ne??e.source.source_cid,anchor:i.cite.anchor,...i.cite.quote?{quote:i.cite.quote}:{}};if(i.matches_existing&&!r.hasNode(i.matches_existing.cid)){g.push({code:"UNKNOWN_MATCH",detail:`${i.temp_ref}: matches_existing ${i.matches_existing.cid} is not in the graph`});continue}let x=i.matches_existing?.cid??(r.hasNode(b)?b:null);if(x&&r.superseded.has(x)){let u=r.tipOf(x);x=r.superseded.has(u)?null:u}if(x&&i.matches_existing&&(_.matches_existing[i.temp_ref]=x),x&&i.matches_existing&&(r.trust.get(x)??null)==="derived"){let u=i.updated?.criteria??[];if(i.changed&&u.length>0&&Ee(u)==="ops"&&(h.resolution==="approved"||h.resolution==="edited")){g.push({code:"UC_UNREVIEWED",detail:`${i.temp_ref}: merge target ${x.slice(0,19)} is unreviewed (derived) \u2014 bless it first (kane-cli context review) and re-propose the merge`});continue}let S=(t.probeHits??[]).find(I=>I.tempRef===i.temp_ref&&I.candidateCid===x);w.push({tempRef:i.temp_ref,candidate_cid:x,score:S?.score??1,scorer:S?.scorer??"lexical_fallback"}),x=null}if(x){if(i.changed&&(h.resolution==="approved"||h.resolution==="edited")){let u=i.updated;if(!u||Object.keys(u).length===0){g.push({code:"CHANGED_NEEDS_PAYLOAD",detail:`${i.temp_ref}: changed:true needs an updated{...} payload naming the moved fields`});continue}let S=r.getNode(x)?.content??{},I=u.criteria??[],V=I.length>0?Ee(I):"flat";if(V==="mixed"){g.push({code:"CRITERIA_SHAPE_MIXED",detail:`${i.temp_ref}.updated.criteria mixes op-shaped (keep/set/remove) and {text, cite} entries \u2014 emit ONE shape for the whole array`});continue}if(V==="ops"){let U=I,H=S.criteria??[],q=g.length;Ve(i.temp_ref,U,H,g);for(let[de,ue]of U.entries())ue.op==="set"&&(!ue.cite||!ue.cite.anchor)&&g.push({code:"MISSING_CITE",detail:`${i.temp_ref}.updated.criteria[${de}]: a set op carries the proposing source's cite`});if(g.length>q)continue;let k=U.filter(de=>de.op!=="remove").map(de=>de.text),J=fe({title:h.edit?.title??u.title??String(S.title??i.title),...u.description??S.description?{description:u.description??S.description}:{},...h.edit?.summary??u.summary??S.summary?{summary:h.edit?.summary??u.summary??S.summary}:{},...u.actors??S.actors?{actors:u.actors??S.actors}:{},...u.value??S.value?{value:u.value??S.value}:{},risk:h.edit?.risk??u.risk??String(S.risk??i.risk),...k.length>0?{criteria:k}:{}}),X=ne("usecase",J);if(X!==x){for(let $ of ie("usecase",J))g.push({code:$.code,detail:`${i.temp_ref}: ${$.detail}`});L.push({cid:X,label:se.USECASE,content:J});for(let $ of _e(i)){let z=$.source_id??e.source.source_id,B=f.get(z);if(!B){g.push({code:"CITE_SOURCE_UNKNOWN",detail:`${i.temp_ref}: cite source ${JSON.stringify(z)} is not in read_basis`});continue}let Z={source_id:z,source_cid:B,anchor:$.anchor,...$.quote?{quote:$.quote}:{}};P.push({ecid:K("DERIVES",B,X,Z),type:O.DERIVES,src:B,dst:X,props:Z})}let ue=me(r,x).flatMap($=>r.edgesInto($)).filter($=>$.type===O.DERIVES&&typeof $.props.claim=="string");for(let $ of U){if($.op!=="keep")continue;let z=new Set;for(let B of ue){let Z=B.props;if(Z.claim!==$.text)continue;let Re=`${Z.source_id}|${Z.source_cid}|${Z.anchor}`;if(z.has(Re))continue;z.add(Re);let be={...B.props};P.push({ecid:K("DERIVES",B.src,X,be),type:O.DERIVES,src:B.src,dst:X,props:be})}}for(let $ of U){if($.op!=="set")continue;let z=$.cite.source_id??e.source.source_id,B=f.get(z);if(!B){g.push({code:"CITE_SOURCE_UNKNOWN",detail:`${i.temp_ref}: set cite source ${JSON.stringify(z)} is not in read_basis`});continue}let Z={source_id:z,source_cid:B,anchor:$.cite.anchor,...$.cite.quote?{quote:$.cite.quote}:{},claim:$.text};P.push({ecid:K("DERIVES",B,X,Z),type:O.DERIVES,src:B,dst:X,props:Z})}for(let $ of U)$.op==="remove"&&y.push({about:x,ref:$.ref,text:$.text,reason:$.reason});C(i.temp_ref,{resolution:"supersede",supersedeTarget:x,reason:h.reason??`criteria merge: ${e.source.source_id} (${U.filter($=>$.op==="keep").length} kept, ${U.filter($=>$.op==="set").length} set, ${U.filter($=>$.op==="remove").length} removed)`},X),G.push({id:X,kind:"review-item",resolution:h.resolution,edit:h.resolution==="edited"?{...h.edit}:null,reason:null,by:o});continue}}else{let U=I.map(k=>typeof k=="string"?{text:k,cite:void 0}:k),H=fe({title:h.edit?.title??u.title??String(S.title??i.title),...u.description??S.description?{description:u.description??S.description}:{},...h.edit?.summary??u.summary??S.summary?{summary:h.edit?.summary??u.summary??S.summary}:{},...u.actors??S.actors?{actors:u.actors??S.actors}:{},...u.value??S.value?{value:u.value??S.value}:{},risk:h.edit?.risk??u.risk??String(S.risk??i.risk),...u.criteria?U.length>0?{criteria:U.map(k=>k.text)}:{}:S.criteria?{criteria:S.criteria}:{}}),q=ne("usecase",H);if(q!==x){for(let k of ie("usecase",H))g.push({code:k.code,detail:`${i.temp_ref}: ${k.detail}`});L.push({cid:q,label:se.USECASE,content:H}),P.push({ecid:K("DERIVES",ee.source_cid,q,ee),type:O.DERIVES,src:ee.source_cid,dst:q,props:ee});for(let k of U){if(!k.cite)continue;let J={source_id:e.source.source_id,source_cid:e.source.source_cid,anchor:k.cite.anchor,...k.cite.quote?{quote:k.cite.quote}:{},claim:k.text};P.push({ecid:K("DERIVES",J.source_cid,q,J),type:O.DERIVES,src:J.source_cid,dst:q,props:J})}C(i.temp_ref,{resolution:"supersede",supersedeTarget:x,reason:h.reason??`matches-but-changed: ${e.source.source_id} moved (${Object.keys(u).join(", ")})`},q),G.push({id:q,kind:"review-item",resolution:h.resolution,edit:h.resolution==="edited"?{...h.edit}:null,reason:null,by:o});continue}for(let k of U){if(!k.cite)continue;let J={source_id:e.source.source_id,source_cid:e.source.source_cid,anchor:k.cite.anchor,...k.cite.quote?{quote:k.cite.quote}:{},claim:k.text};P.push({ecid:K("DERIVES",J.source_cid,x,J),type:O.DERIVES,src:J.source_cid,dst:x,props:J})}}}if(i.changed&&h.resolution==="skipped"){let u=i.updated?.criteria??[];u.length>0&&Ee(u)==="ops"&&G.push({id:x,kind:"pending_update",resolution:"pending",edit:{temp_ref:i.temp_ref,source_id:e.source.source_id,updated:i.updated},reason:i.change_note??null,by:o})}if(h.resolution!=="rejected"){for(let u of _e(i)){let S=u.source_id??e.source.source_id,I=f.get(S);if(!I){g.push({code:"CITE_SOURCE_UNKNOWN",detail:`${i.temp_ref}: cite source ${JSON.stringify(S)} is not in read_basis`});continue}let V={source_id:S,source_cid:I,anchor:u.anchor,...u.quote?{quote:u.quote}:{}};P.push({ecid:K("DERIVES",I,x,V),type:O.DERIVES,src:I,dst:x,props:V})}(h.resolution==="approved"||h.resolution==="edited"||h.resolution==="supersede")&&G.push({id:x,kind:"review-item",resolution:"approved",edit:null,reason:null,by:o}),h.resolution==="supersede"&&C(i.temp_ref,h,x)}continue}for(let u of ie("usecase",ve))g.push({code:u.code,detail:`${i.temp_ref}: ${u.detail}`});for(let u of le(O.DERIVES,"source","usecase",ee))g.push({code:u.code,detail:`${i.temp_ref}: ${u.detail}`});L.push({cid:b,label:se.USECASE,content:ve}),v.set(i.temp_ref,b),P.push({ecid:K("DERIVES",ee.source_cid,b,ee),type:O.DERIVES,src:ee.source_cid,dst:b,props:ee});for(let u of _e(i).slice(1)){let S=u.source_id??e.source.source_id,I=f.get(S);if(!I){g.push({code:"CITE_SOURCE_UNKNOWN",detail:`${i.temp_ref}: cite source ${JSON.stringify(S)} is not in read_basis`});continue}let V={source_id:S,source_cid:I,anchor:u.anchor,...u.quote?{quote:u.quote}:{}};for(let U of le(O.DERIVES,"source","usecase",V))g.push({code:U.code,detail:`${i.temp_ref}: ${U.detail}`});P.push({ecid:K("DERIVES",I,b,V),type:O.DERIVES,src:I,dst:b,props:V})}for(let u of i.criteria??[]){let S=u.cite.source_id??e.source.source_id,I=f.get(S);if(!I){g.push({code:"CITE_SOURCE_UNKNOWN",detail:`${i.temp_ref}: criterion cite source ${JSON.stringify(S)} is not in read_basis`});continue}let V={source_id:S,source_cid:I,anchor:u.cite.anchor,...u.cite.quote?{quote:u.cite.quote}:{},claim:u.text};P.push({ecid:K("DERIVES",V.source_cid,b,V),type:O.DERIVES,src:V.source_cid,dst:b,props:V})}for(let u of i.depends_on_hint??[]){let S=H=>H.toLowerCase().trim().replace(/\s+/g," "),I=null,V=r.resolve(u);if(V&&!V.superseded&&r.nodeLabel.get(V.cid)===se.USECASE&&(I=V.cid),!I){for(let{cid:H,content:q}of r.byLabel(se.USECASE))if(!r.superseded.has(H)&&S(String(q.title??""))===S(u)){I=H;break}}if(!I){let H=L.find(q=>q.label===se.USECASE&&S(String(q.content.title??""))===S(u));H&&(I=H.cid)}!I||I===b||Ye(r,O.DEPENDS_ON,b,I,W)||W.some(H=>H.src===b&&H.dst===I)||(P.push({ecid:K(O.DEPENDS_ON,b,I,{reason:"extract hint"}),type:O.DEPENDS_ON,src:b,dst:I,props:{reason:"extract hint"}}),W.push({src:b,dst:I,type:O.DEPENDS_ON}),(_.depends_on_hint[i.temp_ref]??=[]).push(I))}if((h.resolution==="approved"||h.resolution==="edited"||h.resolution==="supersede")&&r.superseded.get(b)===null&&!p.has(b)&&Q.push({kind:"node",old:b,new:b,reason:`re-minted after tombstone via review by ${o.id}`,by:o}),n){let u=De("usecase",S=>m.has(S),r.names.keys());u!==null&&!r.nameOf.has(b)&&(m.add(u),oe.push({cid:b,slug:u,by:o}))}h.resolution==="approved"?G.push({id:b,kind:"review-item",resolution:"approved",edit:null,reason:null,by:o}):h.resolution==="edited"?G.push({id:b,kind:"review-item",resolution:"edited",edit:{...h.edit},reason:null,by:o}):h.resolution==="rejected"?G.push({id:b,kind:"review-item",resolution:"rejected",edit:null,reason:h.reason??null,by:o}):h.resolution==="supersede"&&(G.push({id:b,kind:"review-item",resolution:"approved",edit:null,reason:h.reason??null,by:o}),C(i.temp_ref,h,b))}if(g.length)return{record:null,errors:g};let R=new Date().toISOString(),F=(e.sources?.length??0)>1||(e.extraction_claims?.length??0)>0,A;if(F){let i=[];if(e.extraction_claims==null)i.push({source_id:e.source.source_id,source_cid:e.source.source_cid,completeness:"complete",...a?{extractor_version:a}:{},at:R});else{let h=new Map(e.extraction_claims.map(j=>[j.source_id,j.completeness]));for(let j of e.sources??[e.source]){let Y=h.get(j.source_id)??null;Y!==null&&i.push({source_id:j.source_id,source_cid:j.source_cid,completeness:Y,...a?{extractor_version:a}:{},at:R})}}A=i}else A=e.source.source_cid;let D=[];for(let i of t.probeHits??[])D.push({...v.has(i.tempRef)?{new_cid:v.get(i.tempRef)}:{},candidate_cid:i.candidateCid,score:i.score,scorer:i.scorer,probe_basis:null});for(let i of w){let h=v.get(i.tempRef);D.some(j=>j.new_cid===h&&j.candidate_cid===i.candidate_cid)||D.push({...h!==void 0?{new_cid:h}:{},candidate_cid:i.candidate_cid,score:i.score,scorer:i.scorer,probe_basis:null})}let M=t.eventIds&&t.eventIds.length>0?t.eventIds:t.sid?ze(r,t.sid,"extract",1):void 0;return{record:re(s,{ts:R,proposal_id:c,...c!=null?{extraction_of:A}:{},...c!=null&&a?{extractor_version:a}:{},...y.length>0?{criteria_removed:y}:{},...D.length>0?{dedup_hits:D}:{},nodes:L,edges:P,review:G,supersessions:Q,...oe.length>0?{names:oe}:{},...t.judgements&&t.judgements.length>0?{judgements:t.judgements}:{},...M?{event_ids:M}:{},...t.sid?{sid:t.sid}:{},source_head_moves:{}},{expectPrev:E,intent:{v:1,verb:"extract",args:te({proposal:e,proposalId:c,verdicts:Object.fromEntries(l),by:o,flags:{allowStaleBasis:d??null,autoName:n??null,extractorVersion:a??null,sid:t.sid??null},judgements:t.judgements??null,probeHits:t.probeHits??null,eventIds:M??null}),pins:_},provenance:t.provenance}).record,errors:null}}function Mt(t){let{contextDir:s,graph:r,verdicts:e,by:c}=t,l=[],o=[],d=[],a=[],n=[],E=new Set,f={verdicts:{},supersedeTarget:{}},_=new Map;for(let[y,v]of e){if(v.resolution!=="edited")continue;let w=r.resolve(y);if(!w||w.superseded)continue;let N=r.getNode(w.cid);if(!N)continue;let T={...N.content,...v.edit?.title!==void 0?{title:v.edit.title}:{},...v.edit?.summary!==void 0?{summary:v.edit.summary}:{},...v.edit?.risk!==void 0?{risk:v.edit.risk}:{}};if(ie(N.label,T).length>0)continue;let L=ne(N.label,T);L===w.cid||Ce(r,w.cid,L)||_.set(w.cid,L)}for(let[y,v]of e){if(v.resolution==="skipped")continue;let w=r.resolve(y);if(!w){l.push({code:"UNKNOWN_NODE",detail:`${y} names nothing in the graph`});continue}if(w.superseded){l.push({code:"SUPERSEDED_TARGET",detail:`${y} is superseded \u2014 review the tip (${w.tip})`});continue}let N=w.cid;if(f.verdicts[y]=N,v.resolution==="approved")a.push({id:N,kind:"review-item",resolution:"approved",edit:null,reason:null,by:c});else if(v.resolution==="rejected")t.holdArchives?a.push({id:N,kind:"pending_archive",resolution:"pending",edit:null,reason:v.reason??null,by:c}):a.push({id:N,kind:"review-item",resolution:"rejected",edit:null,reason:v.reason??null,by:c});else if(v.resolution==="edited"){if(E.has(N)){l.push({code:"DUPLICATE_TARGET",detail:`${y}: this node was already superseded by another verdict in this batch \u2014 one verdict per node`});continue}let T=r.getNode(N);if(!T){l.push({code:"UNKNOWN_NODE",detail:`${y}: node file unreadable`});continue}let L={...T.content,...v.edit?.title!==void 0?{title:v.edit.title}:{},...v.edit?.summary!==void 0?{summary:v.edit.summary}:{},...v.edit?.risk!==void 0?{risk:v.edit.risk}:{}},P=ie(T.label,L);if(P.length>0){for(let Q of P)l.push({code:Q.code,detail:`${y}: ${Q.detail}`});continue}let W=ne(T.label,L);if(W===N){a.push({id:N,kind:"review-item",resolution:"approved",edit:null,reason:null,by:c});continue}if(Ce(r,N,W)){l.push({code:"SUPERSEDE_CYCLE",detail:`${y}: edit reproduces an already-superseded version (supersession cycle guard) \u2014 re-edit forward or redesign`});continue}let G=Me({graph:r,oldTip:N,newCid:W,newLabel:T.label,by:c,reason:`re-blessed onto ${W} (edited in review)`,dstRedirect:_});if(G.errors.length>0){for(let Q of G.errors)l.push({code:"REBLESS_REFUSED",detail:`${y}: ${Q}`});continue}o.push({cid:W,label:T.label,content:L}),d.push(...G.edges),E.add(N),n.push({kind:"node",old:N,new:W,reason:v.reason??"edited in review",by:c}),n.push(...G.supersessions),a.push({id:W,kind:"review-item",resolution:"edited",edit:{...v.edit},reason:null,by:c})}else if(v.resolution==="supersede"){let T=Pe(r,v.supersedeTarget,N,E);if("error"in T){l.push({code:T.error.code,detail:`${y}: ${T.error.detail}`});continue}E.add(T.targetCid),f.supersedeTarget[y]=T.targetCid,t.holdArchives?a.push({id:T.targetCid,kind:"pending_archive",resolution:"pending",edit:null,reason:`supersede by ${N}${v.reason?` \u2014 ${v.reason}`:""}`,by:c}):(n.push({kind:"node",old:T.targetCid,new:N,reason:v.reason??`superseded via review by ${c.id}`,by:c}),a.push({id:N,kind:"review-item",resolution:"approved",edit:null,reason:v.reason??null,by:c}))}}return l.length?{record:null,errors:l}:a.length===0&&n.length===0?{record:null,errors:[{code:"NO_VERDICTS",detail:"every item was skipped \u2014 nothing to commit"}]}:{record:re(s,{ts:new Date().toISOString(),proposal_id:null,nodes:o,edges:d,review:a,supersessions:n,source_head_moves:{}},{expectPrev:r.latestHash,intent:{v:1,verb:"review",args:te({verdicts:Object.fromEntries(e),by:c,holdArchives:t.holdArchives??null}),pins:f},provenance:t.provenance}).record,errors:null}}function Pt(t){let{contextDir:s,graph:r,survivor:e,merged:c,reason:l,by:o}=t,d=r.resolve(e),a=r.resolve(c);return d?a?d.superseded||a.superseded?{record:null,errors:[{code:"ALREADY_SUPERSEDED",detail:"a side of the pair is already superseded \u2014 the pair is drained"}]}:d.cid===a.cid?{record:null,errors:[{code:"SELF_SUPERSEDE",detail:"a pair cannot merge a node into itself"}]}:{record:re(s,{ts:new Date().toISOString(),proposal_id:null,nodes:[],edges:[],review:[],supersessions:[{kind:"node",old:a.cid,new:d.cid,reason:l??`pair merge: duplicate of ${e}`,by:o}],source_head_moves:{}},{expectPrev:r.latestHash,intent:{v:1,verb:"pair-merge",args:te({survivor:e,merged:c,reason:l??null,by:o}),pins:{survivor:d.cid,merged:a.cid}},provenance:t.provenance}).record,errors:null}:{record:null,errors:[{code:"UNKNOWN_NODE",detail:`${c} names nothing in the graph`}]}:{record:null,errors:[{code:"UNKNOWN_NODE",detail:`${e} names nothing in the graph`}]}}function Vt(t){let{contextDir:s,graph:r,assignments:e,by:c}=t,l=new Set(t.reassign??[]),o=[],d=[],a=new Set,n={};for(let{ref:f,slug:_}of e){if(!pe.test(_)){o.push({code:"BAD_SLUG",detail:`${JSON.stringify(_)} \u2014 slugs are kebab-case ${String(pe)}`});continue}let g=r.resolve(f);if(!g){o.push({code:"UNKNOWN_REF",detail:`${f} names nothing in the graph`});continue}if(g.superseded){o.push({code:"SUPERSEDED_TARGET",detail:`${f} is superseded \u2014 name the tip instead (${g.tip})`});continue}let y=r.names.get(_);if(y!==void 0&&!r.superseded.has(y)&&y!==g.cid&&!l.has(_)||a.has(_)){o.push({code:"SLUG_TAKEN",detail:`${_} already names ${y??"another node in this record"}`});continue}a.add(_),n[f]=g.cid,d.push({cid:g.cid,slug:_,by:c})}return o.length?{record:null,errors:o}:d.length===0?{record:null,errors:[{code:"NO_ASSIGNMENTS",detail:"nothing to name"}]}:{record:re(s,{ts:new Date().toISOString(),proposal_id:null,nodes:[],edges:[],review:[],supersessions:[],names:d,source_head_moves:{}},{expectPrev:r.latestHash,intent:{v:1,verb:"names",args:te({assignments:e,by:c,...t.reassign&&t.reassign.length>0?{reassign:t.reassign}:{}}),pins:{refs:n}},provenance:t.provenance}).record,errors:null}}function Lt(t){let{contextDir:s,graph:r,sourceId:e,reason:c,by:l}=t,o=r.heads.get(e);return o===void 0?{record:null,errors:[{code:"UNKNOWN_SOURCE",detail:`no source ${e} in the graph`}]}:o===null?{record:null,errors:[{code:"ALREADY_RETIRED",detail:`source ${e} is already retired`}]}:{record:re(s,{ts:new Date().toISOString(),proposal_id:null,nodes:[],edges:[],review:[],supersessions:[{kind:"node",old:o,new:null,reason:c??`retired source ${e}`,by:l}],source_head_moves:{[e]:null},names:[]},{expectPrev:r.latestHash,intent:{v:1,verb:"retire",args:te({sourceId:e,reason:c??null,by:l}),pins:{head:o}},provenance:t.provenance}).record,errors:null}}function Gt(t){let s=ie("gap",t.content);if(s.length>0)return{ok:!1,refusal:`defer gap failed schema validation: ${s.map(l=>l.detail).join("; ")}`};let r=ne("gap",t.content),e={reason:"reconcile change deferred"},c=t.annotates?[{ecid:K(O.ANNOTATES,r,t.annotates,e),type:O.ANNOTATES,src:r,dst:t.annotates,props:e}]:[];for(let l=0;;l++)try{return re(t.contextDir,{ts:new Date().toISOString(),proposal_id:null,nodes:[{cid:r,label:"gap",content:t.content}],edges:c,review:[],supersessions:[],source_head_moves:{}},{expectPrev:ge(t.contextDir),intent:{v:1,verb:"gap",args:te({content:t.content,annotates:t.annotates??null}),pins:{annotates:t.annotates??null}},provenance:t.provenance}),{ok:!0,cid:r}}catch(o){if(o instanceof Ie){if(l<3)continue;return{ok:!1,refusal:"concurrent activity kept moving the store \u2014 try the card again"}}throw o}}function Ut(t){let s=t.graph.byLabel("gap").filter(r=>(t.gaps===void 0||t.gaps.includes(r.cid))&&r.content.kind==="reconcile_deferred"&&typeof r.content.uc=="string"&&t.graph.tipOf(r.content.uc)===t.targetTip&&(t.sourceId===void 0||r.content.basis?.source_id===void 0||r.content.basis.source_id===t.sourceId)&&!t.graph.superseded.has(r.cid)&&t.graph.trust.get(r.cid)!=="archived");if(s.length===0)return{resolved:0};for(let r=0;;r++)try{return re(t.contextDir,{ts:new Date().toISOString(),proposal_id:null,nodes:[],edges:[],review:[],supersessions:s.map(e=>({kind:"node",old:e.cid,new:t.resolvedBy,reason:"reconcile change resolved by a later verdict",by:t.by})),source_head_moves:{}},{expectPrev:ge(t.contextDir),intent:{v:1,verb:"gap-close",args:te({targetTip:t.targetTip,resolvedBy:t.resolvedBy,sourceId:t.sourceId??null,by:t.by}),pins:{gaps:s.map(e=>e.cid)}},provenance:t.provenance}),{resolved:s.length}}catch(e){if(e instanceof Ie){if(r<3)continue;return{resolved:0}}throw e}}export{he as a,He as b,Ae as c,ye as d,Ce as e,Me as f,pe as g,Ye as h,kt as i,_e as j,Ee as k,Ve as l,Dt as m,Xe as n,ze as o,Ze as p,At as q,Mt as r,Pt as s,Vt as t,Lt as u,Gt as v,Ut as w,Le as x,Ge as y,rt as z,ke as A,De as B,pt as C,We as D,ft as E,me as F};
@@ -1,6 +1,6 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as Y,b as Z,c as nn,d as en,e as tn}from"./chunk-CAO3XRA2.js";import{b as rn,c as sn}from"./chunk-P7YZ3PU3.js";import{n as X,p as P}from"./chunk-RSSOJ3L2.js";import{a as jn}from"./chunk-6YGTRKDT.js";import{e as Pn}from"./chunk-UR6MHSHU.js";function on(i){return{command:"start",...i}}function an(i,e,o){return{command:"run",run_id:i,kind:e,...o}}function un(i){return{command:"cancel",...i?{run_id:i}:{}}}function dn(i){return{command:"ask_user_response",answer:i}}function ln(){return{command:"shutdown"}}var z=Symbol("run-queue-end"),G=class{items=[];waiting=null;ended=!1;error=null;push(e){if(this.waiting){let{resolve:o}=this.waiting;this.waiting=null,o(e)}else this.items.push(e)}end(){if(this.ended=!0,this.waiting){let{resolve:e}=this.waiting;this.waiting=null,e(z)}}fail(e){if(this.error=e,this.waiting){let{reject:o}=this.waiting;this.waiting=null,o(e)}}next(){return this.items.length>0?Promise.resolve(this.items.shift()):this.error?Promise.reject(this.error):this.ended?Promise.resolve(z):new Promise((e,o)=>{this.waiting={resolve:e,reject:o}})}},D=class{env;runner;log;sessionId;spawnFn;proc=null;activeRun=null;pendingReady=null;shuttingDown=!1;finalized=!1;exitInfo=null;exitedUnexpectedly=!1;exitResolve;exited;constructor(e){this.env=e.env,this.runner=e.runner,this.log=e.log,this.sessionId=e.sessionId,this.spawnFn=e.spawn??Z;let o;this.exited=new Promise(c=>{o=c}),this.exitResolve=o}async start(e){if(this.proc)throw new Error("PersistentRunner.start called twice");this.proc=this.spawnFn({env:this.env,runner:this.runner,log:this.log,sessionId:this.sessionId}),this.consume();let o=new Promise((c,g)=>{this.pendingReady={resolve:c,reject:g}});this.writeCommand(on(e)),await o}async*run(e,o,c){if(!this.proc)throw new Error("PersistentRunner.run called before start");if(this.finalized)throw new Error(`v16-runner is not running (exited code=${this.exitInfo?.code??"null"}, signal=${this.exitInfo?.signal??"none"}) \u2014 cannot start run '${e}'`);if(this.activeRun)throw new Error(`PersistentRunner.run overlap: '${this.activeRun.runId}' still in flight`);let g=new G,w={runId:e,queue:g};this.activeRun=w,this.writeCommand(an(e,o,c));try{for(;;){let v=await g.next();if(v===z||(yield v,v.type==="run_end"&&(v.run_id===void 0||v.run_id===e)))break}}finally{this.activeRun===w&&(this.activeRun=null)}}sendUserResponse(e){this.writeCommand(dn(e))}cancel(e){this.writeCommand(un(e))}kill(){this.proc?.child.kill("SIGTERM")}async shutdown(){this.shuttingDown=!0,this.proc&&(this.writeCommand(ln()),await this.exited)}get stderr(){return this.proc?.getStderr()??""}get diedUnexpectedly(){return this.exitedUnexpectedly}writeCommand(e){let o=JSON.stringify(e)+`
2
+ import{a as Y,b as Z,c as nn,d as en,e as tn}from"./chunk-KOL6ZWOQ.js";import{b as rn,c as sn}from"./chunk-P7YZ3PU3.js";import{n as X,p as P}from"./chunk-RSSOJ3L2.js";import{a as jn}from"./chunk-6YGTRKDT.js";import{e as Pn}from"./chunk-UR6MHSHU.js";function on(i){return{command:"start",...i}}function an(i,e,o){return{command:"run",run_id:i,kind:e,...o}}function un(i){return{command:"cancel",...i?{run_id:i}:{}}}function dn(i){return{command:"ask_user_response",answer:i}}function ln(){return{command:"shutdown"}}var z=Symbol("run-queue-end"),G=class{items=[];waiting=null;ended=!1;error=null;push(e){if(this.waiting){let{resolve:o}=this.waiting;this.waiting=null,o(e)}else this.items.push(e)}end(){if(this.ended=!0,this.waiting){let{resolve:e}=this.waiting;this.waiting=null,e(z)}}fail(e){if(this.error=e,this.waiting){let{reject:o}=this.waiting;this.waiting=null,o(e)}}next(){return this.items.length>0?Promise.resolve(this.items.shift()):this.error?Promise.reject(this.error):this.ended?Promise.resolve(z):new Promise((e,o)=>{this.waiting={resolve:e,reject:o}})}},D=class{env;runner;log;sessionId;spawnFn;proc=null;activeRun=null;pendingReady=null;shuttingDown=!1;finalized=!1;exitInfo=null;exitedUnexpectedly=!1;exitResolve;exited;constructor(e){this.env=e.env,this.runner=e.runner,this.log=e.log,this.sessionId=e.sessionId,this.spawnFn=e.spawn??Z;let o;this.exited=new Promise(c=>{o=c}),this.exitResolve=o}async start(e){if(this.proc)throw new Error("PersistentRunner.start called twice");this.proc=this.spawnFn({env:this.env,runner:this.runner,log:this.log,sessionId:this.sessionId}),this.consume();let o=new Promise((c,g)=>{this.pendingReady={resolve:c,reject:g}});this.writeCommand(on(e)),await o}async*run(e,o,c){if(!this.proc)throw new Error("PersistentRunner.run called before start");if(this.finalized)throw new Error(`v16-runner is not running (exited code=${this.exitInfo?.code??"null"}, signal=${this.exitInfo?.signal??"none"}) \u2014 cannot start run '${e}'`);if(this.activeRun)throw new Error(`PersistentRunner.run overlap: '${this.activeRun.runId}' still in flight`);let g=new G,w={runId:e,queue:g};this.activeRun=w,this.writeCommand(an(e,o,c));try{for(;;){let v=await g.next();if(v===z||(yield v,v.type==="run_end"&&(v.run_id===void 0||v.run_id===e)))break}}finally{this.activeRun===w&&(this.activeRun=null)}}sendUserResponse(e){this.writeCommand(dn(e))}cancel(e){this.writeCommand(un(e))}kill(){this.proc?.child.kill("SIGTERM")}async shutdown(){this.shuttingDown=!0,this.proc&&(this.writeCommand(ln()),await this.exited)}get stderr(){return this.proc?.getStderr()??""}get diedUnexpectedly(){return this.exitedUnexpectedly}writeCommand(e){let o=JSON.stringify(e)+`
3
3
  `;try{this.proc?.child.stdin?.write(o)}catch{}}async consume(){if(!this.proc)return;try{for await(let c of this.proc.events){if(c.type==="ready"){this.onReady();continue}this.routeEvent(c)}}catch(c){this.log?.("error","PERSISTENT_RUNNER_STREAM_ERROR","Runner stdout stream errored",{error:c instanceof Error?c.message:String(c)})}let{code:e,signal:o}=await this.proc.exited;this.onExit(e,o)}onReady(){if(this.pendingReady){let{resolve:e}=this.pendingReady;this.pendingReady=null,e()}}routeEvent(e){let o=this.activeRun;if(!o){this.log?.("warn","PERSISTENT_RUNNER_ORPHAN_EVENT","Runner event with no active run",{event_type:e.type});return}o.queue.push(e)}onExit(e,o){if(!this.finalized){if(this.finalized=!0,this.exitInfo={code:e,signal:o},this.shuttingDown||(this.exitedUnexpectedly=!0),this.exitResolve({code:e,signal:o}),this.pendingReady){let{reject:c}=this.pendingReady;this.pendingReady=null,c(new Error(`v16-runner exited before ready (code=${e}, signal=${o??"none"})`))}if(this.activeRun){let{queue:c}=this.activeRun;if(this.activeRun=null,this.shuttingDown)c.end();else{let g=this.proc?.getStderr()?.slice(-500)??"";c.fail(new Error(`v16-runner exited unexpectedly mid-run (code=${e}, signal=${o??"none"})${g?`
4
- ${g}`:""}`))}}}}};var p=Pn(jn(),1);function cn(i){let e={cdp_endpoint:i.cdp_endpoint,ws_endpoint:i.ws_endpoint,width:i.width,height:i.height,headless:i.headless,model:i.model,max_steps:i.max_steps,network_ws:i.network_ws,network_sse:i.network_sse,session_id:i.session_id};return i.device&&(e.device=i.device),i.auth&&(e.auth=i.auth),i.disable_ask_user&&(e.disable_ask_user=!0),i.username&&(e.username=i.username),i.access_key&&(e.access_key=i.access_key),e}function j(i,e){let o=null,c=(g,w)=>{for(let v=0;v<g.length;v++){let _=g[v],h=[...w,v];e(_)&&(o===null||h.length>o.length)&&(o=h),_.children&&_.children.length>0&&c(_.children,h)}};return c(i,[]),o}function N(i,e,o){if(e.length===0)return[...i];let c=e[0],g=[...i],w=g[c];if(e.length===1)g[c]=o(w);else{let v=e.slice(1),_=N(w.children??[],v,o);g[c]={...w,children:_}}return g}function pn(){return{steps:[],maxOrdinal:0}}function Nn(i,e){if(e.type==="run_start"&&e.child_id)return e.environment?.resolution?{...i,resolution:e.environment.resolution}:i;if(e.type==="run_start"){let o=sn(i.runnerEnvironment,rn(e.environment));if(o)return{...i,runnerEnvironment:o,...o.resolution?{resolution:o.resolution}:{}}}if(e.type==="step_end"&&typeof e.ordinal=="number"&&e.id){let o={id:e.id,ordinal:e.ordinal,status:e.status,...e.kind?{kind:e.kind}:{},...typeof e.duration=="number"?{duration_ms:Math.round(e.duration*1e3)}:{},...typeof e.action_id=="string"&&e.action_id?{action_id:e.action_id}:{}};return{...i,steps:[...i.steps,o],maxOrdinal:Math.max(i.maxOrdinal,e.ordinal)}}return i}function V(i){let e=i.indexOf(": ");return e>0&&e<15?i.slice(e+2):i}function W(i){return i.map(e=>{let o=e.children?W(e.children):e.children;return e.status==="running"?{...e,status:"stopped",phase:void 0,children:o}:o!==e.children?{...e,children:o}:e})}function Gn(i,e,o,c,g){let[w,v]=(0,p.useState)(!1),[_,h]=(0,p.useState)([]),[hn,T]=(0,p.useState)(null),[fn,B]=(0,p.useState)(null),[mn,k]=(0,p.useState)(null),[vn,J]=(0,p.useState)(null),[gn,H]=(0,p.useState)([]),[Rn,K]=(0,p.useState)(null),[Sn,yn]=(0,p.useState)(void 0),[wn,$]=(0,p.useState)(0),y=(0,p.useRef)(null),E=(0,p.useRef)(null),S=(0,p.useRef)(null),b=(0,p.useRef)(0),F=(0,p.useRef)(!1),U=(0,p.useRef)(pn()),O=(0,p.useRef)(null),xn=(0,p.useCallback)(async(m,x)=>{let Q=O.current;if(Q)try{await Q}catch{}h([]),T(null),B(null),k(null),J(null),H([]),K(null),yn(m.max_steps),v(!0),S.current=null,b.current=0,U.current=pn();let I=y.current;if(I&&E.current!==m.session_id){try{I.kill()}catch{}y.current=null,E.current=null,$(n=>n+1),I=null}if(!I){let n=Y();if(!n){k("v16-runner not found. Build the binary with `cd v16-runner && python build.py` or ensure Python is available."),v(!1);return}let d=en({environment:x?.environment,mode:x?.mode,assertionMode:x?.assertionMode,finalValidation:x?.finalValidation,username:m.username,accessKey:m.access_key,sessionId:m.session_id});m.device?.platform&&await nn(d,m.device);let u=new D({env:d,runner:n,log:x?.log,sessionId:m.session_id});y.current=u,E.current=m.session_id,I=u,X("runner",()=>{try{u.kill()}catch{}});let s=cn(m);try{await u.start(s)}catch(a){k(a instanceof Error?a.message:String(a)),v(!1),P("runner","Runner start failed"),y.current=null,E.current=null,$(t=>t+1);return}}let M={...m};delete M.run_id,tn(M,{environment:x?.environment});let In=`run-${m.run_index}`,Cn=m.mode==="replay"?"replay":"author",L=I,q=(async()=>{F.current=!1;for await(let n of L.run(In,Cn,M)){if(F.current)break;switch(U.current=Nn(U.current,n),n.type){case"run_start":if(n.child_id)break;if(S.current&&!S.current.isSingleFlow){let d=b.current;b.current++,h(u=>u.map((s,a)=>a===d?{...s,status:"running"}:s.status==="running"&&!s.children?.some(t=>t.status==="running")?{...s,status:s.children?.some(t=>t.status==="failed")?"failed":"passed"}:s))}break;case"bifurcation":{let d=n.flows??[],u=n.count??d.length,s={flows:d,isSingleFlow:n.is_single_flow??u<=1};J(s),S.current=s,b.current=0,h(d.map((a,t)=>({index:t+1,objective:a??`Flow ${t+1}`,status:"pending"})));break}case"step_start":{e?.("STEP_START",`Step ${n.index} started`,{index:n.index,objective:n.objective,child_id:n.child_id});let d=n.index,u=n.objective??`Step ${d}`,s=n.child_id,a=S.current&&!S.current.isSingleFlow;if(s)h(t=>{let r=j(t,l=>l.branchChildId===s)??j(t,l=>l.status==="running");return r?N(t,r,l=>{let f=(l.children??[]).map(R=>R.status==="running"&&R.childId===s?{...R,status:"stopped",phase:void 0}:R);return f.push({index:d,objective:u,status:"running",childId:s}),{...l,children:f}}):t});else if(a){let t=Math.max(0,b.current-1);h(r=>{let l=[...r];if(t>=l.length)return r;let f={...l[t]},C=[...f.children??[]].map(A=>A.status==="running"&&A.childId===void 0?{...A,status:"stopped",phase:void 0}:A);return C.push({index:d,objective:u,status:"running"}),f.children=C,f.status="running",l[t]=f,l})}else h(t=>{let r=W(t);return r.some(f=>f.index===d)?r.map(f=>f.index===d?{...f,status:"running",objective:u}:f):[...r,{index:d,objective:u,status:"running"}]});break}case"step_event":{e?.("STEP_EVENT",`Step ${n.index} ${n.event}`,{index:n.index,phase:n.event,action_type:n.action_type,detail:n.detail,child_id:n.child_id});let d=n.child_id,u=S.current&&!S.current.isSingleFlow;if(n.event==="cm_init"&&n.checkpoint_count!=null){H(s=>[...s,n.checkpoint_count]);break}if(n.event==="replay_started"){K({recordingLength:n.recording_length??0});break}if(n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&o?.(n.detail),d){let s=t=>{if(t.index!==n.index||t.childId!==d)return t;let r={phase:n.event};return n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(r.objective=n.detail),n.action_type&&(r.actionType=n.action_type),{...t,...r}},a=t=>t.map(r=>{let l=s(r);return l!==r?l:r.children&&r.children.length>0?{...r,children:a(r.children)}:r});h(t=>t.map(r=>r.children?{...r,children:a(r.children)}:r))}else if(u){let s=Math.max(0,b.current-1);h(a=>{let t=[...a];if(s>=t.length)return a;let r={...t[s]},l=[...r.children??[]];if(!l.some(R=>R.index===n.index&&R.childId===void 0))l.push({index:n.index,objective:`Step ${n.index}`,status:"running",phase:n.event,actionType:n.action_type});else for(let R=0;R<l.length;R++){if(l[R].index!==n.index||l[R].childId!==void 0)continue;let C={phase:n.event};n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(C.objective=n.detail),n.action_type&&(C.actionType=n.action_type),l[R]={...l[R],...C}}return r.children=l,t[s]=r,t})}else h(s=>s.some(t=>t.index===n.index)?s.map(t=>{if(t.index!==n.index)return t;let r={phase:n.event};return n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(r.objective=n.detail),n.action_type&&(r.actionType=n.action_type),{...t,...r}}):[...W(s),{index:n.index,objective:`Step ${n.index}`,status:"running",phase:n.event,actionType:n.action_type}]);break}case"step_end":{e?.("STEP_END",`Step ${n.index} ${n.status}`,{index:n.index,status:n.status,duration:n.duration,summary:n.summary,child_id:n.child_id}),c?.();let d=n.child_id,u=S.current&&!S.current.isSingleFlow;if(d){let s=t=>t.index===n.index&&t.childId===d?{...t,status:n.status,duration:n.duration,phase:void 0,objective:t.objective.startsWith("Step ")?V(n.summary||t.objective):t.objective}:t,a=t=>t.map(r=>{let l=s(r);return l!==r?l:r.children&&r.children.length>0?{...r,children:a(r.children)}:r});h(t=>t.map(r=>r.children?{...r,children:a(r.children)}:r))}else if(u){let s=Math.max(0,b.current-1);h(a=>{let t=[...a];if(s>=t.length)return a;let r={...t[s]},l=(r.children??[]).map(f=>f.index===n.index&&f.childId===void 0?{...f,status:n.status,duration:n.duration,phase:void 0,objective:f.objective.startsWith("Step ")?V(n.summary||f.objective):f.objective}:f);return r.children=l,t[s]=r,t})}else h(s=>s.map(a=>a.index===n.index?{...a,status:n.status,duration:n.duration,phase:void 0,objective:a.objective.startsWith("Step ")?V(n.summary||a.objective):a.objective}:a));{let a=S.current&&!S.current.isSingleFlow?Math.max(0,b.current-1):0,t=typeof n.ordinal=="number"&&n.id?{ordinal:n.ordinal,id:n.id}:void 0;i?.(n.index,a,n.child_id,t)}break}case"child_agent_start":{let d=n.objective??"",u=n.child_id;h(s=>{let a=j(s,t=>t.status==="running");return a?N(s,a,t=>({...t,objective:`${d} (branch)`,phase:`child: ${d.slice(0,50)}`,branchObjective:d,branchChildId:u})):s});break}case"child_agent_end":{let d=n.child_id,u=`child ${n.success?"done":"failed"}`;h(s=>{let a=j(s,t=>t.branchChildId===d);return a?N(s,a,t=>({...t,phase:u})):s.map(t=>t.phase?.startsWith("child:")?{...t,phase:u}:t)});break}case"describe_trigger":g?.(n);break;case"ask_user":T(n.question??"");break;case"run_end":h(d=>d.map(u=>u.status==="running"?{...u,status:n.status,phase:void 0}:u)),v(!1),B(n);break;case"error":v(!1),k(n.message??"Runner error"),h(d=>d.map(u=>u.status==="running"?{...u,status:"failed",phase:void 0}:u));break}}})().catch(n=>{if(y.current!==L)return;let u=[n instanceof Error?n.message:String(n)],s=L.stderr;s&&!u.join(`
4
+ ${g}`:""}`))}}}}};var p=Pn(jn(),1);function cn(i){let e={cdp_endpoint:i.cdp_endpoint,ws_endpoint:i.ws_endpoint,width:i.width,height:i.height,headless:i.headless,model:i.model,max_steps:i.max_steps,network_ws:i.network_ws,network_sse:i.network_sse,session_id:i.session_id};return i.device&&(e.device=i.device),i.auth&&(e.auth=i.auth),i.disable_ask_user&&(e.disable_ask_user=!0),i.username&&(e.username=i.username),i.access_key&&(e.access_key=i.access_key),e}function j(i,e){let o=null,c=(g,w)=>{for(let v=0;v<g.length;v++){let _=g[v],h=[...w,v];e(_)&&(o===null||h.length>o.length)&&(o=h),_.children&&_.children.length>0&&c(_.children,h)}};return c(i,[]),o}function N(i,e,o){if(e.length===0)return[...i];let c=e[0],g=[...i],w=g[c];if(e.length===1)g[c]=o(w);else{let v=e.slice(1),_=N(w.children??[],v,o);g[c]={...w,children:_}}return g}function pn(){return{steps:[],maxOrdinal:0}}function Nn(i,e){if(e.type==="run_start"&&e.child_id)return e.environment?.resolution?{...i,resolution:e.environment.resolution}:i;if(e.type==="run_start"){let o=sn(i.runnerEnvironment,rn(e.environment));if(o)return{...i,runnerEnvironment:o,...o.resolution?{resolution:o.resolution}:{}}}if(e.type==="step_end"&&typeof e.ordinal=="number"&&e.id){let o={id:e.id,ordinal:e.ordinal,status:e.status,...e.kind?{kind:e.kind}:{},...typeof e.duration=="number"?{duration_ms:Math.round(e.duration*1e3)}:{},...typeof e.action_id=="string"&&e.action_id?{action_id:e.action_id}:{}};return{...i,steps:[...i.steps,o],maxOrdinal:Math.max(i.maxOrdinal,e.ordinal)}}return i}function K(i){let e=i.indexOf(": ");return e>0&&e<15?i.slice(e+2):i}function V(i){return i.map(e=>{let o=e.children?V(e.children):e.children;return e.status==="running"?{...e,status:"stopped",phase:void 0,children:o}:o!==e.children?{...e,children:o}:e})}function Gn(i,e,o,c,g){let[w,v]=(0,p.useState)(!1),[_,h]=(0,p.useState)([]),[hn,T]=(0,p.useState)(null),[fn,B]=(0,p.useState)(null),[mn,k]=(0,p.useState)(null),[vn,W]=(0,p.useState)(null),[gn,J]=(0,p.useState)([]),[Rn,H]=(0,p.useState)(null),[Sn,yn]=(0,p.useState)(void 0),[wn,$]=(0,p.useState)(0),y=(0,p.useRef)(null),E=(0,p.useRef)(null),S=(0,p.useRef)(null),b=(0,p.useRef)(0),F=(0,p.useRef)(!1),U=(0,p.useRef)(pn()),O=(0,p.useRef)(null),xn=(0,p.useCallback)(async(m,x)=>{let Q=O.current;if(Q)try{await Q}catch{}h([]),T(null),B(null),k(null),W(null),J([]),H(null),yn(m.max_steps),v(!0),S.current=null,b.current=0,U.current=pn();let I=y.current;if(I&&E.current!==m.session_id){try{I.kill()}catch{}y.current=null,E.current=null,$(n=>n+1),I=null}if(!I){let n=Y();if(!n){k("v16-runner not found. Build the binary with `cd v16-runner && python build.py` or ensure Python is available."),v(!1);return}let d=en({environment:x?.environment,mode:x?.mode,assertionMode:x?.assertionMode,finalValidation:x?.finalValidation,username:m.username,accessKey:m.access_key,sessionId:m.session_id});m.device?.platform&&await nn(d,m.device);let u=new D({env:d,runner:n,log:x?.log,sessionId:m.session_id});y.current=u,E.current=m.session_id,I=u,X("runner",()=>{try{u.kill()}catch{}});let s=cn(m);try{await u.start(s)}catch(a){k(a instanceof Error?a.message:String(a)),v(!1),P("runner","Runner start failed"),y.current=null,E.current=null,$(t=>t+1);return}}let M={...m};delete M.run_id,tn(M,{environment:x?.environment});let In=`run-${m.run_index}`,Cn=m.mode==="replay"?"replay":"author",L=I,q=(async()=>{F.current=!1;for await(let n of L.run(In,Cn,M)){if(F.current)break;switch(U.current=Nn(U.current,n),n.type){case"run_start":if(n.child_id)break;if(S.current&&!S.current.isSingleFlow){let d=b.current;b.current++,h(u=>u.map((s,a)=>a===d?{...s,status:"running"}:s.status==="running"&&!s.children?.some(t=>t.status==="running")?{...s,status:s.children?.some(t=>t.status==="failed")?"failed":"passed"}:s))}break;case"bifurcation":{let d=n.flows??[],u=n.count??d.length,s={flows:d,isSingleFlow:n.is_single_flow??u<=1};W(s),S.current=s,b.current=0,h(d.map((a,t)=>({index:t+1,objective:a??`Flow ${t+1}`,status:"pending"})));break}case"step_start":{e?.("STEP_START",`Step ${n.index} started`,{index:n.index,objective:n.objective,child_id:n.child_id});let d=n.index,u=n.objective??`Step ${d}`,s=n.child_id,a=S.current&&!S.current.isSingleFlow;if(s)h(t=>{let r=j(t,l=>l.branchChildId===s)??j(t,l=>l.status==="running");return r?N(t,r,l=>{let f=(l.children??[]).map(R=>R.status==="running"&&R.childId===s?{...R,status:"stopped",phase:void 0}:R);return f.push({index:d,objective:u,status:"running",childId:s}),{...l,children:f}}):t});else if(a){let t=Math.max(0,b.current-1);h(r=>{let l=[...r];if(t>=l.length)return r;let f={...l[t]},C=[...f.children??[]].map(A=>A.status==="running"&&A.childId===void 0?{...A,status:"stopped",phase:void 0}:A);return C.push({index:d,objective:u,status:"running"}),f.children=C,f.status="running",l[t]=f,l})}else h(t=>{let r=V(t);return r.some(f=>f.index===d)?r.map(f=>f.index===d?{...f,status:"running",objective:u}:f):[...r,{index:d,objective:u,status:"running"}]});break}case"step_event":{e?.("STEP_EVENT",`Step ${n.index} ${n.event}`,{index:n.index,phase:n.event,action_type:n.action_type,detail:n.detail,child_id:n.child_id});let d=n.child_id,u=S.current&&!S.current.isSingleFlow;if(n.event==="cm_init"&&n.checkpoint_count!=null){J(s=>[...s,n.checkpoint_count]);break}if(n.event==="replay_started"){H({recordingLength:n.recording_length??0});break}if(n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&o?.(n.detail),d){let s=t=>{if(t.index!==n.index||t.childId!==d)return t;let r={phase:n.event};return n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(r.objective=n.detail),n.action_type&&(r.actionType=n.action_type),{...t,...r}},a=t=>t.map(r=>{let l=s(r);return l!==r?l:r.children&&r.children.length>0?{...r,children:a(r.children)}:r});h(t=>t.map(r=>r.children?{...r,children:a(r.children)}:r))}else if(u){let s=Math.max(0,b.current-1);h(a=>{let t=[...a];if(s>=t.length)return a;let r={...t[s]},l=[...r.children??[]];if(!l.some(R=>R.index===n.index&&R.childId===void 0))l.push({index:n.index,objective:`Step ${n.index}`,status:"running",phase:n.event,actionType:n.action_type});else for(let R=0;R<l.length;R++){if(l[R].index!==n.index||l[R].childId!==void 0)continue;let C={phase:n.event};n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(C.objective=n.detail),n.action_type&&(C.actionType=n.action_type),l[R]={...l[R],...C}}return r.children=l,t[s]=r,t})}else h(s=>s.some(t=>t.index===n.index)?s.map(t=>{if(t.index!==n.index)return t;let r={phase:n.event};return n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(r.objective=n.detail),n.action_type&&(r.actionType=n.action_type),{...t,...r}}):[...V(s),{index:n.index,objective:`Step ${n.index}`,status:"running",phase:n.event,actionType:n.action_type}]);break}case"step_end":{e?.("STEP_END",`Step ${n.index} ${n.status}`,{index:n.index,status:n.status,duration:n.duration,summary:n.summary,child_id:n.child_id}),c?.();let d=n.child_id,u=S.current&&!S.current.isSingleFlow;if(d){let s=t=>t.index===n.index&&t.childId===d?{...t,status:n.status,duration:n.duration,phase:void 0,objective:t.objective.startsWith("Step ")?K(n.summary||t.objective):t.objective}:t,a=t=>t.map(r=>{let l=s(r);return l!==r?l:r.children&&r.children.length>0?{...r,children:a(r.children)}:r});h(t=>t.map(r=>r.children?{...r,children:a(r.children)}:r))}else if(u){let s=Math.max(0,b.current-1);h(a=>{let t=[...a];if(s>=t.length)return a;let r={...t[s]},l=(r.children??[]).map(f=>f.index===n.index&&f.childId===void 0?{...f,status:n.status,duration:n.duration,phase:void 0,objective:f.objective.startsWith("Step ")?K(n.summary||f.objective):f.objective}:f);return r.children=l,t[s]=r,t})}else h(s=>s.map(a=>a.index===n.index?{...a,status:n.status,duration:n.duration,phase:void 0,objective:a.objective.startsWith("Step ")?K(n.summary||a.objective):a.objective}:a));{let a=S.current&&!S.current.isSingleFlow?Math.max(0,b.current-1):0,t=typeof n.ordinal=="number"&&n.id?{ordinal:n.ordinal,id:n.id}:void 0;i?.(n.index,a,n.child_id,t)}break}case"child_agent_start":{let d=n.objective??"",u=n.child_id;h(s=>{let a=j(s,t=>t.status==="running");return a?N(s,a,t=>({...t,objective:`${d} (branch)`,phase:`child: ${d.slice(0,50)}`,branchObjective:d,branchChildId:u})):s});break}case"child_agent_end":{let d=n.child_id,u=`child ${n.success?"done":"failed"}`;h(s=>{let a=j(s,t=>t.branchChildId===d);return a?N(s,a,t=>({...t,phase:u})):s.map(t=>t.phase?.startsWith("child:")?{...t,phase:u}:t)});break}case"describe_trigger":g?.(n);break;case"ask_user":T(n.question??"");break;case"run_end":h(d=>d.map(u=>u.status==="running"?{...u,status:n.status,phase:void 0}:u)),v(!1),B(n);break;case"error":v(!1),k(n.message??"Runner error"),h(d=>d.map(u=>u.status==="running"?{...u,status:"failed",phase:void 0}:u));break}}})().catch(n=>{if(y.current!==L)return;let u=[n instanceof Error?n.message:String(n)],s=L.stderr;s&&!u.join(`
5
5
  `).includes(s)&&u.push(s),k(u.join(`
6
6
  `)),v(!1),h(a=>a.map(t=>t.status==="running"?{...t,status:"failed",phase:void 0}:t)),P("runner","Runner died mid-run"),y.current=null,E.current=null,$(a=>a+1)});O.current=q,q.finally(()=>{O.current===q&&(O.current=null)})},[i,e,o,c,g]),_n=(0,p.useCallback)(m=>{y.current?.sendUserResponse(m),T(null)},[]),bn=(0,p.useCallback)(()=>{let m=y.current;m&&(m.cancel(),v(!1),T(null))},[]),En=(0,p.useCallback)(async()=>{let m=y.current;if(m){try{await Promise.race([m.shutdown(),new Promise(x=>setTimeout(x,5e3))])}catch{}P("runner","Runner shut down"),y.current=null,E.current=null,$(x=>x+1)}},[]),kn=(0,p.useCallback)(()=>{h([]),B(null),k(null)},[]);return(0,p.useEffect)(()=>()=>{F.current=!0,P("runner","Component unmounted"),y.current=null,E.current=null},[]),{isRunning:w,steps:_,askingUser:hn,lastRunEnd:fn,runError:mn,bifurcationInfo:vn,cmInitCounts:gn,replayInfo:Rn,maxSteps:Sn,sessionGen:wn,startRun:xn,sendAnswer:_n,cancelRun:bn,shutdownRunner:En,clearLastRun:kn,getEvidenceState:()=>U.current}}export{D as a,cn as b,pn as c,Nn as d,Gn as e};
@@ -0,0 +1,5 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ var c=1;function l(e){return e==="agent"?"ndjson":"human"}function f(){return!!(process.stdin.isTTY&&process.stdout.isTTY)}var d=/^(∷ |· |→ |✓ |✗ |… )/;function g(e){return e===0?"complete":e===2?"refused":e===3?"paused":e===130?"interrupted":"error"}function m(e,r,n={stdout:t=>process.stdout.write(t),stderr:t=>process.stderr.write(t)}){let t=!1,i=s=>{if(e!=="ndjson"||t)return;s.type==="done"&&(t=!0);let{type:u,...o}=s;n.stdout(JSON.stringify({type:u,v:1,verb:r,...o})+`
3
+ `)};return{encoding:e,out:e==="ndjson"?()=>{}:s=>n.stdout(s+`
4
+ `),progress:e==="ndjson"?()=>{}:s=>n.stderr(s.replace(d,"").replace(/…$/,"")+`
5
+ `),event:i,done:(s,u,o)=>(i({type:"done",status:u??g(s),exit_code:s,...o!==void 0&&o.length>0?{next:o}:{}}),s)}}var p=8*1024;function E(e,r){return e.message==null?null:e.message.trim()?e.resume?Buffer.byteLength(e.message,"utf8")>p?`${r==="extract"?"extract":"design"}: --message is over 8KB \u2014 the agent would silently drop it; shorten the statement`:null:`${r==="extract"?"extract":"design"}: --message only rides a resume \u2014 pair it with --resume <sid> (a fresh run takes its direction from the sources)`:`${r==="extract"?"extract":"design"}: --message is empty \u2014 say what you want the agent to know`}function x(e,r,n,t){return e.event({type:"error",message:r,...n?{code:n}:{},...t?{remedy:t}:{}}),e.done(2,"refused")}var a=class extends Error{constructor(n,t,i){super(t);this.code=n;this.remedy=i}};function v(e,r,n){return{out:t=>{r()&&n.test(t)||e.out(t)},emit:t=>{r()&&t.type==="error"&&n.test(String(t.message??""))||e.event(t)}}}export{c as a,l as b,f as c,m as d,p as e,E as f,x as g,a as h,v as i};
@@ -0,0 +1,5 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a as Re}from"./chunk-YYYQ5MVD.js";import{a as $e,b as ve,d as ye,e as Oe}from"./chunk-BB2W35TW.js";import{a as Ee}from"./chunk-ALCE5RLK.js";import{B as Se,c as me,h as _e,o as be}from"./chunk-GP7WD4UY.js";import{a as he}from"./chunk-JQW2QFSX.js";import{H as ge,M as le,c as ue,d as X,m as pe}from"./chunk-3N6IAVD5.js";import{d as g,e as l,f as de,g as ae,h as fe}from"./chunk-AKX4VRRR.js";var xe=/\s@verifies\s+(ac-[\w.:\/-]+(?:\s*,\s*ac-[\w.:\/-]+)*)\s*$/,N=i=>({record:null,errors:i,minted:{},logicalIds:{},superseded:[],warnings:[],finalizedTests:{}});function P(i){return i.toLowerCase().trim().replace(/\s+/g," ")}function we(i,O){let t=i.resolve(O);if(!t||i.nodeLabel.get(t.cid)!==g.USECASE||t.superseded)return[];let p=new Set;for(let{cid:a}of i.byLabel(g.SCENARIO))if(!i.superseded.has(a)&&i.edgesFrom(a).some(h=>h.type===l.BELONGS_TO&&i.tipOf(h.dst)===t.cid)){p.add(a);for(let h of i.edgesInto(a))h.type!==l.AUTOMATES||i.superseded.has(h.src)||p.add(h.src)}return[...p]}function Ye(i){let{contextDir:O,graph:t,sections:p,by:a}=i,h=i.engine??"design@1",y=ge(O);if(t.latestHash!==y)return N([{code:"STALE_BASIS",detail:`graph opened at ${String(t.latestHash)} but chain head is ${String(y)} \u2014 re-open and retry`}]);let R=t.resolve(i.ucRef);if(!R||t.nodeLabel.get(R.cid)!==g.USECASE||R.superseded)return N([{code:"UNKNOWN_UC",detail:`${i.ucRef} is not a live use-case`}]);let $=R.cid,S={ucRef:$,automates:{},verifies:{},reuses:{},scope:{},depends_on:{},exercises:[],scoped_to_repoints:[],judgements:[],body_tags:{},forceScope:[]},b=[],Z=/^design@(\d+)$/.exec(i.templateVersion??""),Te=Z!==null&&Number.parseInt(Z[1],10)>=3,ee=new Map,Ce=(e,s)=>{let n=ee.get(e.source_cid);if(n===void 0){let c=Ee(i.contextDir,t,e.source_cid);n=c?Re(c.toString("utf8")):null,ee.set(e.source_cid,n)}if(n===null)return b.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=me(t.mediaOf(e.source_cid),e,n);if(d.length>0){for(let c of d)b.push({code:"CITE_UNVERIFIED",detail:`${s}: ${c.code}: ${c.detail}`});return!1}return!0},A=[],B=[],C=[],V=[],q=[],v={},L={},z={},x=[],j=[],te=new Set,H=[],U=new Set,w=new Set,Y=[];{let e=i.forceScope??(i.force?we(t,i.ucRef):[]);S.forceScope=[...e];let s=new Set;i.sections.scenarios?.length&&s.add(g.SCENARIO),i.sections.tests?.length&&s.add(g.TEST);for(let n of e)t.superseded.has(n)||(s.has(t.nodeLabel.get(n)??"")?w.add(n):Y.push(n))}let D=new Set,K=e=>!t.superseded.has(e)&&(!w.has(e)||D.has(e)),k=(e,s,n)=>{if(v[e])return v[e];let d=t.resolve(e),c=d?K(d.cid)?d.cid:t.tipOf(d.cid):null;return!d||!c||!K(c)?(b.push({code:"UNKNOWN_REF",detail:`${s}: '${e}' is neither in this payload nor a live committed node`}),null):n&&t.nodeLabel.get(c)!==n?(b.push({code:"ILLEGAL_EDGE",detail:`${s}: '${e}' is a ${t.nodeLabel.get(c)}, expected ${n}`}),null):c},ke=(e,s,n,d)=>{if(t.nameOf.has(s)){L[d]=t.nameOf.get(s);return}let c=Se(e,_=>te.has(_),t.names.keys());c!==null&&(te.add(c),V.push({cid:s,slug:c,by:a}),L[d]=c)},G=(e,s,n,d)=>{for(let _ of de(e,n))b.push({code:_.code,detail:`${s}: ${_.detail}`});let c=ue(e,n);return t.hasNode(c)&&!t.superseded.has(c)?(w.has(c)&&D.add(c),v[s]=c,c):(A.push({cid:c,label:e,content:n}),v[s]=c,ke(e,c,d,s),c)},T=(e,s,n,d,c)=>{let _=X(e,s,n,d);if(t.edgesFrom(s).some(o=>o.ecid===_&&!t.superseded.has(o.ecid))){e===l.AUTOMATES&&U.add(n);return}if(t.superseded.has(_)){b.push({code:"EDGE_RETRACTED",detail:`${c}: this ${e} edge was retracted (${_}) \u2014 retraction is terminal for commits. Add a NEW relationship (different endpoint or props), redesign, or revert the retracting record`});return}let I=t.nodeLabel.get(s)??A.find(o=>o.cid===s)?.label??"(unknown)",M=t.nodeLabel.get(n)??A.find(o=>o.cid===n)?.label??"(unknown)";for(let o of fe(e,I,M,d))b.push({code:o.code,detail:`${c}: ${o.detail}`});let f=_e(t,e,s,n,H);if(f){b.push({code:f.code,detail:`${c}: ${f.detail}`});return}if(e===l.BELONGS_TO||e===l.SCOPED_TO){let o=he(t,{type:e,src:s,dst:n},{pending:H,retracted:new Set(C.flatMap(r=>r.kind==="edge"?[r.ecid]:[])),freed:new Set([...w].filter(r=>!D.has(r)))},c);if(o){b.push(o);return}}if(e===l.AUTOMATES){if(U.has(n)){b.push({code:"CARDINALITY_VIOLATION",detail:`${c}: two automates onto ${n} in one record (strict 1:1)`});return}if(U.add(n),!w.has(n)||D.has(n)){let o=m=>w.has(m)&&!D.has(m);if(t.edgesFrom(s).some(m=>m.type===l.AUTOMATES&&m.dst!==n&&!t.superseded.has(m.dst)&&!o(m.dst))&&t.hasNode(s)){b.push({code:"CARDINALITY_VIOLATION",detail:`${c}: automates from ${s} already has a live edge \u2014 supersede it first`});return}if(t.edgesInto(n).some(m=>m.type===l.AUTOMATES&&m.src!==s&&!t.superseded.has(m.src)&&!o(m.src))){b.push({code:"CARDINALITY_VIOLATION",detail:`${c}: automates onto ${n} already has a live edge \u2014 strict 1:1, supersede it first`});return}}}B.push({ecid:X(e,s,n,d),type:e,src:s,dst:n,props:d}),H.push({src:s,dst:n,type:e})},J=new Set;for(let e of p.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)){b.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&&J.add(e.ref);let d={kind:e.kind,question:n,derived:!0,uc:$,...e.risk?{risk:e.risk}:{},...e.risk_rationale?{risk_rationale:e.risk_rationale}:{},...e.text?{text:e.text}:{},...e.ref?{ref:e.ref}:{}};G(g.GAP,s,d,String(n.header))}let se=new Map;for(let{cid:e,content:s}of t.byLabel(g.SCENARIO))K(e)&&t.edgesFrom(e).some(n=>n.type===l.BELONGS_TO&&t.tipOf(n.dst)===$)&&se.set(P(String(s.title??"")),e);for(let e of p.scenarios??[]){let s=se.get(P(e.title));if(s){b.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}:{}};G(g.SCENARIO,e.temp_ref,n,e.title)}for(let e of p.scenarios??[]){let s=v[e.temp_ref];if(s){T(l.BELONGS_TO,s,$,{},e.temp_ref);for(let n of e.depends_on??[]){let d=k(n,`${e.temp_ref}.depends_on`,g.SCENARIO);d&&((S.depends_on[e.temp_ref]??=[]).push(d),T(l.DEPENDS_ON,s,d,{},`${e.temp_ref}.depends_on`))}}}for(let e of p.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=G(g.AC,e.temp_ref,s,e.text);if(!n)continue;let d=e.scope?.type==="scenario"&&e.scope.ref?k(e.scope.ref,`${e.temp_ref}.scope`,g.SCENARIO):$;d&&d!==$&&(S.scope[e.temp_ref]=d),d&&!t.edgesFrom(n).some(c=>c.type===l.SCOPED_TO&&!t.superseded.has(c.ecid))&&T(l.SCOPED_TO,n,d,{},`${e.temp_ref}.scope`);for(let c of e.cites??[]){if(Te&&!Ce(c,`${e.temp_ref}.cite`))continue;let _={source_id:c.source_id,source_cid:c.source_cid,anchor:c.anchor,...c.quote?{quote:c.quote}:{}};T(l.DERIVES,c.source_cid,n,_,`${e.temp_ref}.cite`)}}for(let e of p.exercises??[]){let s=k(e.scenario,"exercises.scenario",g.SCENARIO),n=k(e.ac,"exercises.ac",g.AC);!s||!n||(S.exercises.push({scenario:s,ac:n}),T(l.EXERCISES,s,n,{},`exercises ${e.scenario}\u2192${e.ac}`))}let ne=0;for(let e of p.scoped_to_repoints??[]){let s=k(e.ac,"scoped_to_repoints.ac",g.AC),n=k(e.to,"scoped_to_repoints.to");if(!s||!n)continue;S.scoped_to_repoints.push({ac:s,to:n});let d=t.edgesFrom(s).find(c=>c.type===l.SCOPED_TO&&!t.superseded.has(c.ecid));if(d&&d.dst===n){ne+=1,x.push(`scoped_to_repoints ${e.ac}: already scoped to ${e.to} \u2014 no-op`);continue}d&&C.push({kind:"edge",ecid:d.ecid,reason:`re-scoped to ${e.to} by ${a.id}`,by:a}),T(l.SCOPED_TO,s,n,{},`scoped_to_repoints ${e.ac}`)}let ie=new Map;if(i.finalizeTestBody)for(let[e,s]of t.nameOf)ie.set(t.tipOf(e),s);let oe=e=>t.nameOf.get(e)??ie.get(t.tipOf(e))??null,re=e=>{if(v[e])return v[e];let s=t.resolve(e);return s?t.names.has(e)&&!t.superseded.has(s.cid)?s.cid:t.tipOf(s.cid):null},Ie=e=>{let s=re(e);if(!s&&i.strict)throw new Error(`UNMAPPED_REF: '${e}' resolves to nothing on this graph`);return s?v[e]?L[e]??oe(s):t.names.has(e)?e:oe(s):null};for(let e of p.tests??[]){for(let f of e.reuses??[])J.has(f)&&b.push({code:"REUSES_EVICTED",detail:`${e.temp_ref}: reuses '${f}' which was budget-evicted \u2014 drop the edge; the dependent gap names the missing @import`});{let f=r=>r==="emulator"||r==="simulator"?r:"web",o=r=>{let u=(p.tests??[]).find(Ae=>Ae.temp_ref===r);if(u)return f(u.target);let m=t.resolve(r),E=m?t.getNode(t.tipOf(m.cid)??m.cid)?.content:void 0;if(typeof E?.target=="string")return f(String(E.target));let ce=/^\s*\[mobile:\s*(emulator|simulator)\]/m.exec(String(E?.test_md_blob??""));return ce?ce[1]:"web"};for(let r of e.reuses??[]){let u=f(e.target),m=o(r);u!==m&&b.push({code:"REUSES_CROSS_SURFACE",detail:`${e.temp_ref}: reuses '${r}' which runs on ${m} while this test runs on ${u} \u2014 a test imports only same-surface units`})}}let s=e.test_md_blob,n=e.definitionId,d=e.objectives_blob;if(i.finalizeTestBody){let f;try{f=i.finalizeTestBody({temp_ref:e.temp_ref,test_md_blob:e.test_md_blob,verifies:e.verifies,reuses:e.reuses??[]},Ie)}catch(o){return N([{code:"FINALIZE_BODY",detail:`${e.temp_ref}: ${o instanceof Error?o.message:String(o)}`}])}f&&(s=f.test_md_blob,n=f.definitionId,d=f.objectives_blob??d,z[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}:{}},_=G(g.TEST,e.temp_ref,c,e.title);if(!_)continue;let I=k(e.automates,`${e.temp_ref}.automates`,g.SCENARIO);I&&(S.automates[e.temp_ref]=I,T(l.AUTOMATES,_,I,{},`${e.temp_ref}.automates`)),S.verifies[e.temp_ref]=[];for(let f of e.verifies){let o=k(f,`${e.temp_ref}.verifies`,g.AC);o&&(S.verifies[e.temp_ref].push(o),T(l.VERIFIES,_,o,{},`${e.temp_ref}.verifies`))}S.reuses[e.temp_ref]=[];for(let f of e.reuses??[]){if(J.has(f))continue;let o=k(f,`${e.temp_ref}.reuses`,g.TEST);o&&(S.reuses[e.temp_ref].push(o),T(l.REUSES,_,o,{},`${e.temp_ref}.reuses`))}for(let f of e.verifies){let o=v[f]??t.resolve(f)?.cid;o&&(t.trust.get(o)??"derived")==="derived"&&!A.some(r=>r.cid===o)?x.push(`${e.temp_ref}: verifies ${f} which is still DERIVED (unapproved) \u2014 committed anyway; approve it in chat or via review`):o&&v[f]===o&&(p.acs??[]).some(r=>r.temp_ref===f)&&x.push(`${e.temp_ref}: verifies ${f} minted in this same record (unapproved) \u2014 committed anyway; approve it in chat`)}if(!String(e.test_md_blob??"").split(`
3
+ `).some(f=>/^##\s/.test(f)&&!/—\s?assert/.test(f)&&xe.test(f))&&e.verifies.length>1){let f=e.check?.verified_against;x.push(`${e.temp_ref}: verifies ${e.verifies.length} ACs but machine-asserts only 1 (check.verified_against=${f!=null?String(f):"?"}) \u2014 the rest ride prose only`)}}let F=[];for(let e of p.tests??[]){let s={};for(let n of De(e.test_md_blob,e.objectives_blob)){let d=re(n);d?s[n]=d:F.push(`${e.temp_ref}: body tag '${n}' resolves to nothing`)}S.body_tags[e.temp_ref]=s,F.push(...Ne(e.temp_ref,s,[...S.verifies[e.temp_ref]??[],...S.reuses[e.temp_ref]??[]]))}if(F.length>0){if(i.strict)return N(F.map(e=>({code:"BODY_EDGE_MISMATCH",detail:e})));x.push(...F.map(e=>`integrity: ${e}`))}let W=[];{let e=(o,r)=>`${o??""}\0${P(String(r??""))}`,s=(o,r)=>i.reason?`${i.reason} \u2014 evolve by ${a.id}${r?` (${r})`:""}`:o,n=new Map;for(let o of A){if(o.label!==g.SCENARIO&&o.label!==g.TEST)continue;let r=e(o.label,o.content.title);n.set(r,[...n.get(r)??[],o.cid])}let d=new Map;for(let o of w){if(D.has(o))continue;let r=e(t.nodeLabel.get(o),t.getNode(o)?.content.title);d.set(r,[...d.get(r)??[],o])}for(let[o,r]of d){let u=n.get(o)??[],m=r.length===1&&u.length===1;for(let E of r)m?(C.push({kind:"node",old:E,new:u[0],reason:s(`--force redesign of ${i.ucRef} by ${a.id} (title-matched successor)`,"title-matched successor"),by:a}),W.push({old:E,next:u[0]})):C.push({kind:"node",old:E,new:null,reason:s(`--force redesign of ${i.ucRef} by ${a.id}`),by:a}),j.push(E)}let c=o=>t.edgesFrom(o).some(r=>r.type!==l.SCOPED_TO?!1:r.dst===$||t.tipOf(r.dst)===$?!0:t.nodeLabel.get(r.dst)===g.SCENARIO&&t.edgesFrom(r.dst).some(u=>u.type===l.BELONGS_TO&&t.tipOf(u.dst)===$)),_=new Map;for(let{cid:o,content:r}of t.byLabel(g.AC)){if(t.superseded.has(o)||!c(o))continue;let u=P(String(r.text??""));_.set(u,[..._.get(u)??[],o])}let I=new Map;for(let o of A){if(o.label!==g.AC)continue;let r=P(String(o.content.text??""));I.set(r,[...I.get(r)??[],o.cid])}for(let[o,r]of _){let u=I.get(o)??[];r.length!==1||u.length!==1||(C.push({kind:"node",old:r[0],new:u[0],reason:s(`AC re-emitted with changed content by ${a.id} (text-matched successor)`,"AC text-matched successor"),by:a}),W.push({old:r[0],next:u[0]}),j.push(r[0]))}let M=new Set(j),f=new Set;for(let o of C)o.kind==="edge"&&f.add(o.ecid);for(let{old:o,next:r}of W)for(let u of t.edgesInto(o))ae(u.type)?.pin?.comparesTo!=="dst_tip"||t.superseded.has(u.src)||M.has(u.src)||f.has(u.ecid)||(C.push({kind:"edge",ecid:u.ecid,reason:`re-blessed onto ${r} (redirect successor of ${o}) by ${a.id}`,by:a}),f.add(u.ecid),B.some(E=>E.type===u.type&&E.src===u.src&&E.dst===r)||t.edgesFrom(u.src).some(E=>E.type===u.type&&E.dst===r))||u.type===l.AUTOMATES&&U.has(r)||T(u.type,u.src,r,u.props,`rebless ${u.type} from ${t.nameOf.get(u.src)??u.src}`)}if(b.length>0)return N(b);if(A.length===0&&B.length===0&&C.length===0&&q.length===0)return Object.keys(v).length>0||ne>0?(x.push("everything in this phase is already current \u2014 nothing re-committed"),{record:null,errors:null,minted:v,logicalIds:L,superseded:[],warnings:x,finalizedTests:z,...i.force||i.forceScope?{forceScopeRemaining:Y}:{}}):N([{code:"EMPTY_DESIGN",detail:"finalize_design produced nothing to commit"}]);if(i.generationTicket){let e=ye(t,i.generationTicket);if(e!==null)return N([e])}let Q=i.eventIds&&i.eventIds.length>0?i.eventIds:i.sid?be(t,i.sid,"design",1):null;return{record:le(O,{ts:new Date().toISOString(),proposal_id:null,nodes:A,edges:B,review:[],supersessions:C,source_head_moves:{},...V.length>0?{names:V}:{},...(()=>{for(let e of p.judgements??[]){let s=e.target?v[e.target]??t.resolve(e.target)?.cid??$:$;S.judgements.push(s),q.push({about:s,rationale:`[${e.kind}] ${e.rationale}`,by:a})}return q.length>0?{judgements:q}:{}})(),design_of:{uc_cid:$,engine:h},...i.generationTicket?{design_generation:Oe(i.generationTicket,$,a)}:{},...Q?{event_ids:Q}:{},...i.sid?{sid:i.sid}:{},...i.phase?{design_phase:{uc_root:$e(t,$),generation:i.generationTicket?.next_gen??ve(t,i.ucRef)?.gen??1,phase:i.phase,completeness:i.phaseCompleteness??"complete"}}:{}},{expectPrev:t.latestHash,intent:{v:1,verb:"design",args:pe({ucRef:i.ucRef,sections:p,by:a,engine:h,force:i.force??!1,forceScope:i.forceScope??null,reason:i.reason??null,generationTicket:i.generationTicket??null,templateVersion:i.templateVersion??null,phase:i.phase??null,phaseCompleteness:i.phaseCompleteness??null,eventIds:Q,sid:i.sid??null}),pins:S},provenance:i.provenance}).record,errors:null,minted:v,logicalIds:L,superseded:j,warnings:x,finalizedTests:z,...i.force||i.forceScope?{forceScopeRemaining:Y}:{}}}function Ne(i,O,t){let p=new Set(Object.values(O));if(p.size===0)return[];let a=new Set(t),h=[];for(let[y,R]of Object.entries(O))a.has(R)||h.push(`${i}: body tag '${y}' has no verifies or reuses edge`);for(let y of a)p.has(y)||h.push(`${i}: edge to ${y} has no body tag`);return h}function De(i,O){let t=[];for(let a of(i??"").split(`
4
+ `)){let h=/^##\s.*?\s@verifies\s+(.+?)\s*$/.exec(a);h&&t.push(...h[1].split(",").map(R=>R.trim()).filter(Boolean));let y=/^@import\s+(\S+)\s*$/.exec(a.trim())??/^## Import: (\S+)\s*$/.exec(a);y&&t.push(y[1])}let p=!1;for(let a of(O??"").split(`
5
+ `)){let h=/^\s*verifies:\s*\[(.*)\]\s*$/.exec(a);if(h){t.push(...h[1].split(",").map(R=>R.trim()).filter(Boolean));continue}if(/^\s*verifies:\s*$/.test(a)){p=!0;continue}let y=p?/^\s*-\s+(\S+)\s*$/.exec(a):null;y?t.push(y[1]):p=!1}return t}function Ke(i,O){let t=[];for(let p of i){let a=p.design_phase;!a||typeof a!="object"||a.uc_root===O&&(typeof a.phase!="string"||typeof a.generation!="number"||t.push({phase:a.phase,generation:a.generation,seq:p.seq,completeness:a.completeness==="partial"?"partial":"complete"}))}return t.sort((p,a)=>p.seq-a.seq)}export{we as a,Ye as b,Ke as c};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{O as u,P as c,b as f}from"./chunk-3N6IAVD5.js";import{existsSync as o,mkdirSync as g,readFileSync as b}from"fs";import{dirname as l,join as m}from"path";function s(t,r){let n=r.startsWith("sha256:")?r.slice(7):r;return m(t,"blobs",n.slice(0,2),n.slice(2))}function F(t,r){return s(t,r)}function p(t){let r=Buffer.concat([Buffer.from("assurance.blob\0","utf8"),t]);return"sha256:"+f(r)}function y(t,r){let n=p(r),i=s(t,n);if(!o(i)){let e=l(i),a=!o(e);g(e,{recursive:!0}),u(i,r),a&&c(l(e))}return n}function S(t,r){let n=s(t,r);return o(n)?b(n):null}export{F as a,p as b,y as c,S as d};
@@ -0,0 +1,5 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{b as G,c as K}from"./chunk-PDXZROJM.js";import{S as $}from"./chunk-CGT4NFQN.js";import{b as q}from"./chunk-5GUD3CIH.js";import{a as yt,b as k}from"./chunk-NBXYL2JT.js";import{a as V}from"./chunk-BPMSNGXQ.js";import{a as z}from"./chunk-DHJSM5DT.js";import{a as M}from"./chunk-NLCCBXXV.js";import{a as R}from"./chunk-RZ4F3BHX.js";import{e as Et}from"./chunk-UR6MHSHU.js";import{readFileSync as L,existsSync as U,readdirSync as te,mkdirSync as F,writeFileSync as w}from"fs";import{readFile as bt,unlink as ee}from"fs/promises";import{join as E}from"path";import{existsSync as Gt,mkdirSync as Kt,readdirSync as _t,writeFileSync as Ht}from"fs";import{join as S}from"path";import{randomUUID as v}from"crypto";var It=["children","instructions","branches","module_content","true_branch","false_branch"];function Y(e){let t=new Map,n=i=>{if(!i||typeof i!="object")return;let r=i;if(Array.isArray(r.operations))for(let o of r.operations){let s=o.operation_id;typeof s=="string"&&s&&!t.has(s)&&t.set(s,r)}for(let o of It){let s=r[o];Array.isArray(s)?s.forEach(n):s&&typeof s=="object"&&n(s)}};return e.forEach(n),t}function W(e,t){let n=new Map;for(let i of e){let r=i.action_id?t.get(i.action_id):void 0;if(!r)continue;let o=n.get(r)??[];o.push(i),n.set(r,o)}return n.size===0?null:[...n].map(([i,r])=>At(i,r))}function vt(e){if(!e.timestamp||e.duration_ms==null)return"";let t=new Date(e.timestamp);return isNaN(t.getTime())?"":new Date(t.getTime()+e.duration_ms).toISOString()}function H(e){if(e!=null)try{return JSON.parse(e)}catch{return e}}function J(e,t,n){let i=e.user_variables,r=typeof i=="string",o;try{o=r?JSON.parse(i):i??[]}catch{return}if(!Array.isArray(o)||o.length===0)return;let s=o.find(c=>t&&c.name===t)??(o.length===1?o[0]:void 0);s&&(s.value=n,e.user_variables=r?JSON.stringify(o):o)}function At(e,t){let n=structuredClone(e),i=t[0],r=t[t.length-1];switch(n.status=t.find(o=>o.status!=="success")?.status??i.status,n.start_timestamp=i.timestamp??n.start_timestamp,n.end_timestamp=vt(r)||n.end_timestamp,n.content_type){case"api":{let o=r.action_params?.api_data?.response;o&&typeof o=="object"&&(n.api_data={...n.api_data??{},response:o},J(n,r.output_variable,o));break}case"script":{r.output_value!=null&&J(n,r.output_variable??n.output_variable_name,r.output_value);break}case"db_query":{r.output_value!=null&&(n.db_details={...n.db_details??{},carried_out_query:H(r.output_value)});break}case"screenshot_command":{let o=H(r.output_value);o&&typeof o=="object"&&(n.smartui_results=o);break}case"network_assertion":case"network_query":break;default:break}return n}var kt="/home/kaneai/Downloads";function O(e){return`${kt}/${e}`}function Q(e){return"FILE__"+e.replace(/[^A-Za-z0-9]/g,"_")}function N(e){let t=e?.media;return!t||!t.name||!t.media_url?null:{media_id:t.media_id??"",name:t.name,media_url:t.media_url,type:t.type??"doc"}}function tt(e){return e?e.includes(`
3
+ `)?e.split(`
4
+ `).map(t=>t.trim()).filter(Boolean):e.split(". ").map(t=>t.trim()).filter(Boolean).map(t=>t.endsWith(".")?t:t+"."):[]}function T(e){return typeof e=="string"&&e.includes("{{secrets.")}var Rt={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"},et={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"},Pt=new Set(["CLICK","TYPE","FILL","HOVER","SCROLL_UNTIL_ELEMENT","UPLOAD_FILE","VISION_QUERY","DRAG_DROP","SELECT"]);function nt(e,t){if(e==="analyze"){let i=t?.action_params?.analyzer_type??"";return et[i]}if(e==="scroll"&&t?.action_params?.into_view===!0)return"SCROLL_UNTIL_ELEMENT";let n=Rt[e];return n||console.warn(`[migrator] UNKNOWN action_type "${e}" \u2014 falling back to "${e.toUpperCase()}"; explicit mapping required`),n??e.toUpperCase()}function it(e,t){if(!e||!t)return"";try{let n=new Date(e);return isNaN(n.getTime())?"":new Date(n.getTime()+t).toISOString()}catch{return""}}function ot(e){try{return JSON.parse(e.output_value??"{}")}catch{return{}}}function St(e){let t=e.output_variable??"";if(!t)return"[]";let i={...ot(e)};return delete i.body,JSON.stringify([{name:t,unique_key:(e.action_id??"").replace(/-/g,"").slice(0,8)||v().replace(/-/g,"").slice(0,8),value:i,variable_description:"API Response"}])}function wt(e,t,n){let i=e.action_params??{},r=Pt.has(t)?"Vision Agent":"Operation Agent",o={operation_type:t};if(t==="OPEN"&&(o.url=i.url??""),t==="SET_VARIABLE"&&(o.variable_name=e.output_variable??i.key??"",o.variable_value=e.output_value??""),t==="UPLOAD_FILE"){let m=N(i);m&&(o.value=O(m.name))}let s={},c={},a=e.action_instruction??"",l=i.text??"",u=i.url??"",_=[["intent",a],["value",l],["url",u]];for(let[m,h]of Object.entries(n)){let I=String(h);if(m.startsWith("secrets."))for(let[y,b]of _)b.includes(I)&&(c[y]=m);for(let[y,b]of _)b.includes(I)&&!(y in s)&&(s[y]=b)}let p=e.action_type,d={operation:e.action_instruction??"",agent:r,operation_dict:o,reasoning:p==="analyze"?i.query??"":e.intent??e.action_instruction??"",variable:s,secrets:c,params:{}};p==="analyze"&&typeof i.code=="string"&&i.code&&(d.code=i.code),p==="analyze"&&typeof i.code_js=="string"&&i.code_js&&(d.code_js=i.code_js),p==="analyze"&&typeof i.condition_expression=="string"&&i.condition_expression&&(d.condition_expression=i.condition_expression),i.uses_websocket===!0&&(d.uses_websocket=!0),i.uses_sse===!0&&(d.uses_sse=!0),p==="analyze"&&i.analyzer_type==="textual_visual"&&(typeof i.wrapped_js=="string"&&(d.wrapped_js=i.wrapped_js),Array.isArray(i.locators)&&(d.locators=i.locators),typeof i.operator=="string"&&(d.operator=i.operator),Array.isArray(i.transforms)&&(d.transforms=i.transforms),typeof i.query=="string"&&(d.query=i.query),typeof i.expected_value=="string"&&(d.expected_value=i.expected_value),typeof i.needs_unit_conversion=="boolean"&&(d.needs_unit_conversion=i.needs_unit_conversion),typeof i.condition=="string"&&(d.condition=i.condition));let f={set_cookies:"cookies",set_clipboard:"text",delete_cookies:"names",set_local_storage:"items",delete_local_storage:"keys"}[p];return f&&i[f]!==void 0&&(d[f]=i[f]),p==="set_clipboard"&&typeof i.html=="string"&&i.html&&(d.html=i.html),d}function xt(e){let t=e.assertion_tree??{};if(typeof t.passed=="boolean")return t.passed;let n=t.sub_results??[];return n.length===0?t.status==="passed":(t.composite_operator??"and")==="or"?n.some(r=>r.passed===!0):n.every(r=>r.passed===!0)}function rt(e){return e.map(t=>({description:t.description??"",store_key:t.store_key??"",expected_value:t.expected??"",extracted_value:t.extracted_value??"",operator:t.operator??"equals",transforms:t.transforms??[]}))}function Ot(e){let t=e.assertion_tree??{},n=t.sub_results??[],i=rt(n);return{operator:[],assertion_operands:[],left_operand:null,right_operand:null,operands:[],sub_results:n,sub_checks:i,composite_operator:t.composite_operator??"and",verification:t.verification??"",claim:t.description??""}}function Nt(e){let n=(e.action_params??{}).assertion_tree??{},i=n.sub_results??[],r=rt(i);return[{operation:e.action_instruction??"",agent:"Operation Agent",operation_dict:{operation_type:"ASSERTION",assertion_tree:{sub_results:i,sub_checks:r,composite_operator:n.composite_operator??"and",verification:"",claim:n.description??e.action_instruction??"",operator:[],assertion_operands:[],left_operand:null,right_operand:null,operands:[]}},variable:{},secrets:{},params:{}}]}function Lt(e,t,n,i){let r=e.visual_data;if(!r||r.x==null||r.y==null)return null;let o=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:o?`${o}/untagged_screenshot/${n}.${i?.get(n)??"png"}`:"",raw_image_sas_url:"",annotated_image_url:"",annotated_image_sas_url:""}}function Tt(e){if(!e)return"";let t=e;return typeof e=="object"&&!Array.isArray(e)&&Array.isArray(e.frameInfo)&&(t=e.frameInfo),!Array.isArray(t)||t.length===0?"":JSON.stringify(t)}function Ct(e){return/^(android|ios)_native$/i.test(e.platform??"")}function st(e,t){return e.map(n=>({...n,type:t?n.strategy??n.type??"native":n.isXPath?"xpath":"css"}))}function jt(e,t,n){let i={selector_target:"",drag_displacement:{},hold_duration_ms:null,move_duration_ms:null,hold_at_destination_ms:null};if(e!=="drag")return i;let r=t.target_selectors,o={};typeof t.direction=="string"&&t.direction&&(o.direction=t.direction,typeof t.fraction=="number"&&(o.fraction=t.fraction));let s=c=>typeof t[c]=="number"?Math.trunc(t[c]):null;return{selector_target:Array.isArray(r)&&r.length>0?st(r,n):"",drag_displacement:o,hold_duration_ms:s("hold_duration_ms"),move_duration_ms:s("move_duration_ms"),hold_at_destination_ms:s("hold_at_destination_ms")}}function X(e,t="",n){let i=e.action_type,r=nt(i,e),o=e.action_params??{},s=e.coordinates??null,c=e.selectors??null,a=!!(c&&c.length>0),l=Ct(e),u=jt(i,o,l),_=e.timestamp??"",p=e.duration_ms??0,d=e.variables_used??{},g=e.action_id??v(),f=v(),m=it(_,p),h="",I="";if(i==="navigate")I=o.url??"",h=I;else if(i==="type"||i==="fill")h=o.text??"";else if(i==="press_key")h=o.key??"";else if(i==="wait")h=String(o.ms??o.timeout_ms??"");else if(i==="evaluate_js")h=o.script??"";else if(i==="upload_files"){let B=N(o);B&&(h=O(B.name))}else i==="analyze"&&r==="SET_VARIABLE"&&(h=e.output_value??"");let y="";i==="go_back"?y="back":i==="go_forward"&&(y="forward");let b=e.action_instruction??"",A=T(h)||T(I)||T(b),x=wt(e,r,d);return{operation_id:g,instruction_id:f,instruction:b,intent:b,operation_start:_,operation_end:m,status:e.status??"",command:r,name:"",target:"",value:h,message:"",operation_dict:"",frame:Tt(e.frame_info),error_message:e.error??"",code_snippet:"",sub_instruction_obj:JSON.stringify(x),test_id:"",test_version:"",action:"",string_to_float:!1,feedback_msg:"",time_taken:"",create_time_stamp:"",update_time_stamp:"",locator_variable:"",locator_variable_name:"",image_url:t?`${t}/test_screenshots/untagged_screenshot/${g}.${n?.get(g)??"png"}`:"",alternative_xpaths:[],attribute:"",value_description:"",url:I,navigation_direction:y,tagified_image_url:"",query_variable_name:e.output_variable??"",query_variable_value:e.output_value??"",query_variable_type:"",expected_value:"",queried_value:"",operator:"",assertion_status:r==="ASSERTION"?xt(o):"",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(o.tab_index??""),tab_identifier:String(o.tab_identifier??""),scroll_value:o.amount??1,scroll_direction:o.direction??"",mi_scroll_payload:{},sleep_duration:0,app_id:"",manual_interaction_tag:"",string_to_float_list:[],js_snippet:i==="evaluate_js"?o.script??"":"",code_error:"",hide:A,dismiss_dialog:!1,use_v2_mobile_tagging:l,multiple_inputs:!1,dialog_action:"",dialog_type:"",is_coordinates_used_for_interaction:s!==null&&!a,element_coordinates_ratio:[],element_bounds_ratio:[],x_coord:a?null:s?.x??null,y_coord:a?null:s?.y??null,target_x_coord:o.target_x??null,target_y_coord:o.target_y??null,source_description:o.source_description??null,target_description:o.target_description??null,use_coordinates:s!==null&&!a,kaneaiMobileTaggingImageLimit:1,clicks_order_code:"se_js_ac",selector:a?st(c,l):"",selector_target:u.selector_target,math_result_variable_name:"",math_result_variable_value:"",expression_tree:r==="ASSERTION"?Ot(o):o.expression_tree??{},assertion_tree:o.assertion_tree??{},assertion_tree_simplified:{},network_throttle:{},is_mobile_offline:!1,autoheal:!1,reprobe:e.reprobe??!1,click_modifier:(o.click_count??1)>=2?{kind:"multi_click",frequency:o.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:o.source_coordinates?{x:o.source_coordinates[0],y:o.source_coordinates[1]}:{},end_coordinates:o.target_coordinates?{x:o.target_coordinates[0],y:o.target_coordinates[1]}:{},element_rect:null,is_canvas:!1,until_condition:"",until_max_retries:0,until_settle_ms:0,api_data:i==="api"?{request:e.action_params?.api_data?.request??{}}:{},output_variables:i==="api"?e.output_variable?{[e.output_variable]:null}:{}:e.output_variable?{[e.output_variable]:e.output_value??""}:{},visual_context:Lt(e,t,g,n),reasoning:i==="analyze"?o.query??"":e.intent??e.action_instruction??""}}function Z(e,t){let n=e.action_type,i=nt(n,e),r=e.timestamp??"",o=e.duration_ms??0,s=it(r,o),c=i==="ASSERTION"||i==="MATHEMATICAL_OPERATION";return{instruction_id:t.instruction_id,instruction_class:c?"non_driver_action":"driver_action",module_id:"",instruction:e.action_instruction??"",command:i,error:null,parent_instruction_id:"",classification_layer_resp:i==="ASSERTION"?Nt(e):[],classification_error:{},operations:[t],status:e.status??"",start_timestamp:r,end_timestamp:s,type:"agent_generated",tags:[],html_paths:[],optional_flag:!1,max_retries:0,retries_delay:0,explicit_wait:0,implicit_wait:0,content_type:n==="api"?"api":n==="analyze"&&e.action_params?.analyzer_type==="api_response"?"api_calls_query":n==="analyze"&&e.action_params?.analyzer_type?.startsWith("devtool_")?e.action_params.analyzer_type.replace("devtool_","devtools_"):"instruction",js_snippet:n==="evaluate_js"?e.action_params?.script??"":"",user_variables:n==="api"?St(e):"[]",api_data:n==="api"?{request:e.action_params?.api_data?.request??{},response:ot(e)}:{},params_used:!1,hard_assertion:i==="ASSERTION"?e.action_params?.failure_condition==="hard":!1,expected_outcome:"",module_execution_index:0,module_version:null,network_throttle:{},isEdited:!1,use_query_assertion_v2:!1,db_query:"",db_details:{},network_assertion_content:{},screenshot_command:"",smartui_contents:{},generative_id:"",plan_id:"",generative_objective:"",error_message:"",error_code:"",reason:"",title:"",used_variables:[],reasoning:n==="analyze"?e.action_params?.query??"":e.intent??e.action_instruction??""}}function Dt(e,t=[]){let n=e.action_params??{},i=n.branches??[],r=n.winning_index??-1,o=n.sub_results??[],s={};for(let a of o){let l=a.sub_results;if(l)for(let u of l){let _=u.store_key;_&&(s[_]=u)}}let c=i.map((a,l)=>{let u=l===r,_=(a.sub_checks??[]).map(p=>{let d=s[p.store_key];return{description:p.description,store_key:p.store_key,expected_value:p.expected_value,stored_value:d?.extracted_value??p.stored_value,operator:p.operator??d?.operator??"equals",transforms:p.transforms??d?.transforms??[]}});if(_.length===0&&a.condition&&o.length>0){let d=o.find(g=>g.branch_index===l)?.sub_results??[];d.length>0&&(_=d.map(g=>({description:g.description??a.condition,store_key:g.store_key??"",expected_value:g.expected??"true",stored_value:g.extracted_value??void 0,operator:g.operator??"equals",transforms:g.transforms??[]})))}return{branch_index:l,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?_:[],composite_operator:a.composite_operator??"and"}});return{content_type:"conditional_block",instruction_id:`if_else_${v().slice(0,8)}`,instruction:e.action_instruction??"",instruction_class:"driver_action",command:"",status:e.status??"success",resolved_branch_index:r,branches:c,generative_id:"",generative_objective:"",variables_used:{},classification_layer_resp:[],classification_error:{},used_variables:[],user_variables:"[]",module_id:"",module_execution_index:0,module_version:"",plan_id:"",optional_flag:!1,max_retries:0,retries_delay:0,explicit_wait:0,implicit_wait:0,error:null,error_message:"",error_code:"",reason:"",start_timestamp:e.timestamp??"",end_timestamp:"",type:"agent_generated",hook:null,hook_type:null,evaluation_context:{},query_variables:{}}}function at(e,t,n){for(let i of e)i.content_type==="instruction"&&"generative_id"in i&&(i.generative_id=t,i.generative_objective=n)}function C(e,t="",n,i){let r=[],o=0;for(;o<e.length;){let s=e[o],c=s.action_type;if(!i?.keepFailedActions&&s.status==="error"&&c!=="assert"&&c!=="if_else"&&c!=="child_agent_start"&&c!=="child_agent_end"&&!(s.until_condition&&!s.error)){o+=1;continue}if(c==="analyze"&&(!et[s.action_params?.analyzer_type??""]||s.action_params?.analyzer_type==="textual_visual"&&s.action_params?.code)){o+=1;continue}if(c==="child_agent_start"){let a=s.action_params?.child_id??"",l=s.action_params?.objective??"",u=[];o+=1;let _=1,p="error",d;for(;o<e.length&&_>0;){let A=e[o],x=A.action_type;if(x==="child_agent_start")_+=1;else if(x==="child_agent_end"&&(_-=1,_===0)){p=A.status??"success",d=A,o+=1;break}_>0&&u.push(A),o+=1}let g=C(u,t,n);at(g,a,l);let f=d?.action_params?.result_code??null,m=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=p==="error";r.push({content_type:"generative_block",instruction_id:`generative_block_${a}`,generative_id:a,objective:l,status:p,children:g,error_message:b?h??null:null,error_code:b?m??null:null,result_code:f??null,bifurcation_context:[],approach_reason:tt(I),one_liner:y??null});continue}else if(c==="child_agent_end"){o+=1;continue}else if(c==="if_else"){o+=1;let a=[];for(;o<e.length&&e[o].action_type==="child_agent_start";){let l=e[o],u=l.action_params?.child_id??"",_=l.action_params?.objective??"",p=[];o+=1;let d=1,g="error";for(;o<e.length&&d>0;){let m=e[o];if(m.action_type==="child_agent_start")d+=1;else if(m.action_type==="child_agent_end"&&(d-=1,d===0)){g=m.status??"success",o+=1;break}d>0&&p.push(m),o+=1}let f=C(p,t,n);a.push(...f)}r.push(Dt(s,a));continue}else if(c==="query_tool"){o+=1;continue}else if(s.until_condition){let a=X(s,t,n),l=Z(s,a),u=typeof s.until_condition_met=="boolean"?s.until_condition_met:s.status==="success";r.push({content_type:"until_block",instruction_id:`until_${v().slice(0,8)}`,condition:s.until_condition,max_retries:s.until_max_retries??10,settle_ms:s.until_settle_ms??500,current_count:0,condition_met:u,children:[l],generative_id:"",generative_objective:"",variables_used:{},status:s.status??"success"})}else{let a=X(s,t,n),l=Z(s,a);r.push(l)}o+=1}return r}function P(e,t="",n,i){let r=[],o=[],s=i?.passthrough,c=s?Y(s.authoredInstructions):null;for(let d of e){if(s&&c&&d.flatIndex!==void 0&&s.replayOnlyFlatIndices.has(d.flatIndex)){let b=W(d.records,c);if(b){for(let A of b)r.push(A),o.push(d.flatIndex);continue}console.warn(`[migrator] replay-only passthrough: no authored operation matched step ${d.flatIndex} (action_id \u2260 any operation_id in the authored blob) \u2014 falling back to this run's records`)}let g=C(d.records,t,n,i);if(g.length===0)continue;let f=v().replace(/-/g,"");at(g,f,d.objective);let m=g.some(b=>"status"in b&&typeof b.status=="string"?b.status==="error"||b.status==="failed":!1),h=d.resultCode?parseInt(d.resultCode,10):null,I=h!==null&&!isNaN(h)&&h>=200,y=m||I?"error":"success";r.push({content_type:"generative_block",instruction_id:`generative_block_${f}`,generative_id:f,objective:d.objective,status:y,children:g,error_message:y==="error"?d.errorMessage??null:null,error_code:y==="error"?d.reasonCode??null:null,result_code:d.resultCode??null,bifurcation_context:[],approach_reason:tt(d.summary),one_liner:d.oneLiner??null}),o.push(d.flatIndex)}let a=r.map((d,g)=>({block:d,flat:o[g]})),l=i?.moduleSpans??[],u=i?.blockSpans??[],_=i?.authoredBlocks??[];l.length>0&&(a=ct(a,l,u,_));let p=dt(u,l);return p.length>0&&(a=j(a,p,_)),{instructions:a.map(d=>d.block)}}function ct(e,t,n,i){let r=[],o=c=>c===void 0?void 0:t.find(a=>c>=a.flatFrom&&c<=a.flatTo),s=0;for(;s<e.length;){let c=o(e[s].flat);if(!c){r.push(e[s]),s++;continue}let a=[];for(;s<e.length&&o(e[s].flat)===c;)a.push(e[s++]);let l=ct(a,c.children,n,i),u=dt(ut(n,c),c.children);u.length>0&&(l=j(l,u,i)),r.push({block:$t(c,l.map(_=>_.block)),flat:a[0].flat})}return r}function lt(e,t){return e.flatFrom>=t.flatFrom&&e.flatTo<=t.flatTo}function ut(e,t){let n=[];for(let i of e)lt(i,t)?n.push(i):n.push(...ut(i.children,t));return n}function dt(e,t){let n=[],i=o=>{for(let s of o)n.push(s),i(s.children)};i(t);let r=o=>o.filter(s=>!n.some(c=>lt(s,c))).map(s=>({...s,children:r(s.children)}));return n.length>0?r(e):e}function j(e,t,n){let i=[...t].sort((l,u)=>l.flatFrom-u.flatFrom),r=[],o=(l,u)=>{r.push({block:zt(l,u,n),flat:l.flatFrom})},s=(l,u)=>l!==void 0&&l>=u.flatFrom&&l<=u.flatTo,c=0,a=0;for(;a<e.length;){let l=e[a].flat;for(;c<i.length&&l!==void 0&&i[c].flatTo<l;)o(i[c++],[]);let u=c<i.length&&s(l,i[c])?i[c]:void 0;if(!u){r.push(e[a]),a++;continue}let _=[];for(;a<e.length&&s(e[a].flat,u);)_.push(e[a++]);o(u,_),c++}for(;c<i.length;)o(i[c++],[]);return r}function Ut(e){let t=new Map;for(let n of e)t.set(n.flat,n);return e.filter(n=>t.get(n.flat)===n)}var Ft=["children","instructions","branches","module_content","true_branch","false_branch"];function Bt(e,t){if(!t)return;let n=[...e];for(;n.length>0;){let i=n.pop();if(!i||typeof i!="object")continue;let r=i;if(r.instruction_id===t&&(r.content_type==="conditional_block"||r.content_type==="until_block"))return r;for(let o of Ft){let s=r[o];Array.isArray(s)?n.push(...s):s&&typeof s=="object"&&n.push(s)}}}function Mt(e,t,n){if(!e)return[];if(t==="while")return Array.isArray(e.children)?e.children:[];let r=(Array.isArray(e.branches)?e.branches:[])[n];return r&&Array.isArray(r.children)?r.children:[]}function zt(e,t,n){let i=Bt(n,e.blockId),r=e.branches.map((o,s)=>{let c=t.filter(u=>u.flat!==void 0&&u.flat>=o.flatFrom&&u.flat<=o.flatTo);e.kind==="while"&&(c=Ut(c));let a=j(c,e.children,n).map(u=>u.block);if(a.length>0)return a;let l=Mt(i,e.kind,s);return l.length===0&&!o.taken&&console.warn(`[migrator] control-flow: branch ${s} of block ${e.blockId||e.instruction} did not run and no authored block matched \u2014 emitted empty`),l});return e.kind==="if"?Vt(e,r,i):qt(e,r[0]??[],i)}function Vt(e,t,n){let i=Array.isArray(n?.branches)?n.branches:[],r=D(t.flat()),o=e.branches.map((s,c)=>{let a=i[c];return{branch_index:c,condition:s.branch_type==="else"?null:s.condition,branch_type:s.branch_type,passed:s.taken,sub_objective:null,custom_event:a?.custom_event??null,children:t[c],sub_checks:Array.isArray(a?.sub_checks)?a.sub_checks:[],composite_operator:a?.composite_operator??"and"}});return{content_type:"conditional_block",instruction_id:e.blockId||`if_else_${v().slice(0,8)}`,instruction:e.instruction,instruction_class:"driver_action",command:"",status:r?"error":"success",resolved_branch_index:e.branches.findIndex(s=>s.taken),branches:o,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:r?.message??"",error_code:r?.code??"",reason:"",start_timestamp:"",end_timestamp:"",type:"agent_generated",hook:null,hook_type:null,evaluation_context:{},query_variables:{}}}function qt(e,t,n){let i=e.whileCfg??{max_retries:5,settle_ms:500,on_exhaust:"fail",iterations:0,condition_met:!1},r=D(t),o=(s,c)=>n&&n[s]!==void 0?n[s]:c;return{content_type:"until_block",instruction_id:e.blockId||`until_${v().slice(0,8)}`,condition:e.instruction,max_retries:i.max_retries,settle_ms:i.settle_ms,current_count:i.iterations,condition_met:i.condition_met,children:t,generative_id:"",generative_objective:"",variables_used:{},status:r?"error":"success",on_exhaust:o("on_exhaust",i.on_exhaust),mode:o("mode",""),check:o("check",""),conditions:o("conditions",[]),connectors:o("connectors",[]),sub_checks:o("sub_checks",[]),composite_operator:o("composite_operator","and")}}function D(e){for(let t of e){let n="status"in t&&typeof t.status=="string"?t.status:"";if(n==="error"||n==="failed"){let i="error_message"in t?t.error_message:void 0,r="error_code"in t?t.error_code:void 0;return{message:i??null,code:r??null}}}return null}function $t(e,t){let n=e.meta,i=(l,u="")=>typeof n[l]=="string"?n[l]:u,r=(l,u=!1)=>typeof n[l]=="boolean"?n[l]:u,o=l=>Array.isArray(n[l])?n[l]:[],s=typeof n.module_version=="number"||typeof n.module_version=="string"?n.module_version:null,c=i("module_id"),a=D(t);return{content_type:$,instruction_id:`module_block_${c}`,module_id:c,module_version:s,module_instance_id:v(),module_name:i("module_name"),module_description:i("module_description"),module_platform:i("module_platform"),creation_mode:i("creation_mode","Agent"),tms_status:i("tms_status","active"),is_validated:r("is_validated"),is_dirty:e.dirty,enrichment_id:i("enrichment_id"),tags:o("tags"),project_ids:o("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 pt(e,t){let n;try{n=_t(e)}catch{return 0}let i=0,r=n.filter(o=>/^\d+$/.test(o)).sort((o,s)=>Number(o)-Number(s));for(let o of r){let s=S(e,o),c=S(s,"logs");if(!Gt(c))continue;let a;try{a=_t(c)}catch{continue}let l=a.filter(p=>p.endsWith("-actions.ndjson")).sort((p,d)=>(parseInt(p,10)||0)-(parseInt(d,10)||0)),u=[];for(let p of l){let d=t.readActions(S(c,p));d.length&&u.push({objective:t.objective??"",records:d})}if(u.length===0)continue;let{instructions:_}=P(u,t.screenshotBaseUrl??"",t.extMap,{keepFailedActions:!0});if(_.length!==0)try{let p=S(s,"auteur");Kt(p,{recursive:!0}),Ht(S(p,"execution.json"),JSON.stringify(t.buildBlob(_),null,2)),i++,t.log?.("info","EVIDENCE_ARCHIVED_ATTEMPT_BLOB","Derived nested attempt blob",{attempt:o,instructions:_.length})}catch(p){t.log?.("debug","EVIDENCE_ARCHIVED_ATTEMPT_BLOB_FAILED","Nested attempt blob derivation failed",{attempt:o,error:p instanceof Error?p.message:String(p)})}}return i}var gt=Et(yt(),1);import{createWriteStream as Jt}from"fs";import{readFile as Yt}from"fs/promises";import{join as Wt,basename as Xt}from"path";import{tmpdir as Zt}from"os";var Qt=["**/screenshots/**","**/annotated/**","**/tcg/**","**/bifurcation/**"];async function ft(e){let t=Wt(Zt(),`${Xt(e)}_artifacts.zip`);return new Promise((n,i)=>{let r=Jt(t),o=(0,gt.default)("zip",{zlib:{level:6}});r.on("close",()=>n(t)),o.on("error",i),o.pipe(r),o.glob("**/*",{cwd:e,ignore:Qt}),o.finalize()})}async function mt(e){return Yt(e)}async function ne(e,t){return bt(q(e,t))}function ie(e){return{key:"artifacts",content_type:"application/zip",filename:`${e}.evidence`}}var ht=class{config;controller;testId;constructor(t){this.config=t,this.controller=new z(t.controllerBaseUrl,t.auth),this.testId=t.testId}log(t,n,i,r){this.config.log?.(t,n,i,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 n=this.config.evidence,i=null;if(this.config.shouldUploadArtifacts!==!1){t("convert","running");let c=this.collectNdjsonPerRun(),a=c.reduce((f,m)=>f+m.records.length,0);this.log("info","PIPELINE_CONVERT","Collected NDJSON records",{total_records:a,run_groups:c.length});let l=this.loadReplayOnlyPassthrough(),{instructions:u}=c.length>0?P(c,this.config.screenshotBaseUrl??"",this.config.screenshotExtMap,{moduleSpans:this.config.moduleSpans,...l?{passthrough:l}:{},...this.config.blockSpans?.length?{blockSpans:this.config.blockSpans,authoredBlocks:this.loadAuthoredBlocks()}:{}}):{instructions:[]};this.log("info","PIPELINE_CONVERT_INSTRUCTIONS","Auteur instructions produced",{count:u.length});let _=this.buildExecutionEnvelope(u),p=Buffer.from(JSON.stringify(_));this.log("info","PIPELINE_CONVERT_BLOB","Blob created",{size_kb:+(p.length/1024).toFixed(1)});let d=E(this.config.sessionDir,"execution.json");w(d,JSON.stringify(_,null,2)),this.log("info","PIPELINE_CONVERT_LOCAL_SAVE","Execution blob saved locally",{path:d});let g=n?.packTestDir??this.config.evidenceRead?.packTestDir;if(g){let f=E(g,"auteur");F(f,{recursive:!0}),w(E(f,"execution.json"),JSON.stringify(_,null,2)),this.log("info","PIPELINE_CONVERT_PACK_COPY","Execution blob copied into pack",{path:E(f,"execution.json")}),this.deriveArchivedAttemptBlobs(g)}if(t("convert","done"),n)i=p;else{t("zip","running"),this.log("info","PIPELINE_ZIP_START","Zipping session",{session_dir:this.config.sessionDir});let f=null,m;try{f=await ft(this.config.sessionDir),m=await mt(f),this.log("info","PIPELINE_ZIP_DONE","Zip complete",{size_mb:+(m.length/1024/1024).toFixed(1),path:f}),t("zip","done",`${(m.length/1024/1024).toFixed(1)}MB`)}finally{f&&await ee(f).catch(()=>{})}t("presign","running"),this.log("info","PIPELINE_PRESIGN_START","Requesting presigned URLs",{url:`${this.config.controllerBaseUrl}/upload/presign`,test_id:this.testId,session_id:this.config.sessionId});let h=await this.controller.getPresignedUrls(this.testId,this.config.sessionId,[{key:"artifacts",content_type:"application/zip",filename:`${this.config.sessionId}_artifacts.zip`},{key:"blob",content_type:"application/json",filename:`${this.config.commitId}.json`}]);this.log("info","PIPELINE_PRESIGN_OK","Presigned URLs received",{artifacts_url:h.urls.artifacts?.blob_url,blob_url:h.urls.blob?.blob_url}),t("presign","done"),t("upload","running"),this.log("info","PIPELINE_UPLOAD_START","Uploading artifacts and blob",{artifact_size_mb:+(m.length/1024/1024).toFixed(1),blob_size_kb:+(p.length/1024).toFixed(1)}),await Promise.all([k(h.urls.artifacts.upload_url,m,"application/zip"),k(h.urls.blob.upload_url,p,"application/json")]),this.log("info","PIPELINE_UPLOAD_OK","Upload complete"),t("upload","done")}}else{let c=this.collectNdjsonPerRun(),a=this.loadReplayOnlyPassthrough(),{instructions:l}=c.length>0?P(c,this.config.screenshotBaseUrl??"",this.config.screenshotExtMap,{keepFailedActions:!0,moduleSpans:this.config.moduleSpans,...a?{passthrough:a}:{},...this.config.blockSpans?.length?{blockSpans:this.config.blockSpans,authoredBlocks:this.loadAuthoredBlocks()}:{}}):{instructions:[]},u=this.buildExecutionEnvelope(l),_=E(this.config.sessionDir,"execution.json");w(_,JSON.stringify(u,null,2)),this.log("info","PIPELINE_LOCAL_SAVE","Execution blob saved locally (no upload)",{path:_});let p=this.config.evidence?.packTestDir??this.config.evidenceRead?.packTestDir;if(p){let d=E(p,"auteur");F(d,{recursive:!0});let g=this.readAuthoredExecution();w(E(d,"execution.json"),g??JSON.stringify(u,null,2)),this.log("info","PIPELINE_CONVERT_PACK_COPY","Execution blob copied into pack (gated)",{path:E(d,"execution.json"),source:g?"authored":"run_envelope"}),this.deriveArchivedAttemptBlobs(p)}t("convert","skipped"),t("zip","skipped"),t("presign","skipped"),t("upload","skipped"),this.log("info","PIPELINE_UPLOAD_SKIPPED","Upload steps skipped (gate disabled)")}if(this.config.shouldReplaceLocalOutput&&this.config.onAtomicReplace){t("atomic_replace","running");try{await this.config.onAtomicReplace(),this.log("info","PIPELINE_ATOMIC_REPLACE_OK","Local output replaced"),t("atomic_replace","done")}catch(c){let a=c instanceof Error?c.message:String(c);throw this.log("error","PIPELINE_ATOMIC_REPLACE_FAILED","Atomic-replace failed",{error:a}),t("atomic_replace","failed",a),c}}else t("atomic_replace","skipped");let r,o;if(this.config.shouldCommit&&!this.config.isFirstRun&&this.config.onCommitLock){t("commit_lock","running");let c=await this.config.onCommitLock();if(c.ok)r=c.testcaseId||void 0,this.log("info","PIPELINE_COMMIT_LOCK_OK","Commit lock acquired",{testcase_id:r??"none",trigger:c.trigger??null,test_instance_id:c.testInstanceId??null}),t("commit_lock","done");else return this.log("error","PIPELINE_COMMIT_LOCK_FAILED","Commit lock failed",{reason:c.reason,message:c.message}),t("commit_lock","failed",`${c.reason??"unknown"}: ${c.message??""}`),{success:!1,testId:this.testId,error:`commit-lock failed: ${c.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 c=new V(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 c.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{o=await this.generateShareLink(r),this.log("info","PIPELINE_SHARE_OK","Share link generated",{share_id:o})}catch(c){this.log("warn","PIPELINE_SHARE_FAILED","Share link failed",{error:String(c)})}if(n&&i){let c=null;t("zip","running");try{await n.sealFn({testcaseId:r,shareId:o}),c=n.sealedPackPath?await bt(n.sealedPackPath):await ne(n.executionId,n.cwd),this.log("info","PIPELINE_EVIDENCE_SEALED","Evidence pack sealed",{execution_id:n.executionId}),this.log("info","PIPELINE_PACK_READ","Sealed pack read",{size_mb:+(c.length/1024/1024).toFixed(1)})}catch(a){let l=a instanceof Error?a.message:String(a);this.log("warn","PIPELINE_EVIDENCE_UPLOAD_SKIPPED","Evidence seal/read failed \u2014 uploading blob only",{execution_id:n.executionId,error:l})}if(c){t("zip","done",`${(c.length/1024/1024).toFixed(1)}MB`),t("presign","running");let a=await this.controller.getPresignedUrls(this.testId,this.config.sessionId,[ie(n.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:+(c.length/1024/1024).toFixed(1),blob_size_kb:+(i.length/1024).toFixed(1)}),await Promise.all([k(a.urls.artifacts.upload_url,c,"application/zip"),k(a.urls.blob.upload_url,i,"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:+(i.length/1024).toFixed(1)}),await k(a.urls.blob.upload_url,i,"application/json"),this.log("info","PIPELINE_UPLOAD_OK","Blob upload complete (pack skipped)"),t("upload","done")}}let s;if(this.config.codeExport?.enabled&&r){let c=!1;try{await this.triggerCodeExport(r),this.log("info","PIPELINE_CODE_EXPORT_START","Code export triggered"),c=!0}catch(a){let l=a instanceof Error?a.message:String(a);this.log("error","PIPELINE_CODE_EXPORT_FAILED","Code export trigger failed; skipping poll",{error:l}),t("code_export","failed",`trigger failed: ${l}`)}if(c){t("code_export","running","Waiting for code generation\u2026");try{s=await this.pollAndDownloadCode(r,t),this.log("info","PIPELINE_CODE_EXPORT_OK","Code export complete",{dir:s}),t("code_export","done",s)}catch(a){let l=a instanceof Error?a.message:String(a);this.log("error","PIPELINE_CODE_EXPORT_FAILED","Code export failed",{error:l}),t("code_export","failed",l)}}}else t("code_export","skipped");return this.log("info","PIPELINE_COMPLETE","Pipeline complete"),{success:!0,testId:this.testId,testcaseId:r,shareId:o,codeExportDir:s}}catch(n){return{success:!1,testId:this.testId,error:n instanceof Error?n.message:String(n)}}}async runCodeExport(t,n){let i=n??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(o){let s=o instanceof Error?o.message:String(o);this.log("error","PIPELINE_CODE_EXPORT_TRIGGER_FAILED","Code export trigger failed; skipping poll",{error:s}),i("code_export","failed",`trigger failed: ${s}`)}if(r){i("code_export","running","Waiting for code generation\u2026");try{let o=await this.pollAndDownloadCode(t,i);return this.log("info","PIPELINE_CODE_EXPORT_OK","Code export complete",{dir:o}),i("code_export","done",o),o}catch(o){let s=o instanceof Error?o.message:String(o);this.log("error","PIPELINE_CODE_EXPORT_FAILED","Code export failed",{error:s}),i("code_export","failed",s);return}}}deriveArchivedAttemptBlobs(t){try{let n=pt(t,{readActions:i=>this.readNdjsonFromFile(i),buildBlob:i=>this.buildExecutionEnvelope(i),objective:this.config.firstObjective,screenshotBaseUrl:this.config.screenshotBaseUrl??"",extMap:this.config.screenshotExtMap,log:(i,r,o,s)=>this.log(i,r,o,s)});n>0&&this.log("info","PIPELINE_ARCHIVED_ATTEMPTS","Nested retry-attempt blobs derived",{count:n})}catch(n){this.log("debug","PIPELINE_ARCHIVED_ATTEMPTS_FAILED","Nested attempt blob pass failed",{error:n instanceof Error?n.message:String(n)})}}collectNdjsonPerRun(){let t=[],n=this.config.runObjectives??[],i=this.config.runMetadata??[],r=this.config.evidence??this.config.evidenceRead;for(let o=0;o<this.config.runDirs.length;o++){let s=this.config.runDirs[o],c=n[o]||this.config.firstObjective,a=i[o],l=r?this.readNdjsonFromFile(E(r.packTestDir,"logs",`${r.runIndices?.[o]??o}-actions.ndjson`)):this.readNdjsonFromDir(s);if(l.length>0){let u=r?.runIndices?.[o]??o,_=this.config.runFlatIndex?.[u];t.push({objective:c,records:l,..._!==void 0?{flatIndex:_}:{},resultCode:a?.resultCode,reasonCode:a?.reasonCode,errorMessage:a?.errorMessage,summary:a?.summary,oneLiner:a?.oneLiner})}}if(t.length===0){let o=E(this.config.sessionDir,"runs");if(U(o))try{let c=te(o,{withFileTypes:!0}).filter(a=>a.isDirectory()).map(a=>a.name).sort();for(let a of c){let l=E(o,a),u=this.readNdjsonFromDir(l);u.length>0&&t.push({objective:this.config.firstObjective,records:u})}}catch{}}return t}readNdjsonFromDir(t){let n=[E(t,"run-test","actions.ndjson"),E(t,"actions.ndjson")];for(let i of n)if(U(i))return this.readNdjsonFromFile(i);return[]}readNdjsonFromFile(t){let n=[];if(!U(t))return n;this.log("debug","PIPELINE_COLLECT_READ","Reading NDJSON file",{path:t});let i=L(t,"utf-8");for(let r of i.split(`
5
+ `)){let o=r.trim();if(o)try{n.push(JSON.parse(o))}catch{}}return n}async generateShareLink(t){let n=`${this.config.shareApiBaseUrl}/lshs/api/v1.0/share-item/generate-sharable-link`;this.log("info","PIPELINE_SHARE_START","Requesting share link",{url:n,testcase_id:t});let i={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 o=r?await this.config.authResolver.fetch(n,i):await R(n,{...i,headers:{...i.headers,Authorization:this.buildAuthHeader()}});if(!o.ok)throw new Error(`Share link API failed: ${o.status} ${await o.text()}`);let s=await o.json();if(!s.shareId)throw new Error("Share link API returned no shareId");return s.shareId}async triggerCodeExport(t){if(!this.config.codeExport)throw new Error("triggerCodeExport called without resolved codeExport config");let{url:n,body:i}=G({tmsBaseUrl:this.config.tmsBaseUrl,testcaseId:t,codeExport:this.config.codeExport,mobile:this.config.mobile});this.log("info","PIPELINE_CODE_EXPORT_POST","Triggering code export",{url:n});let r={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(i)},o=this.config.authResolver?await this.config.authResolver.fetch(n,r):await R(n,{...r,headers:{...r.headers,Authorization:this.buildAuthHeader()}});if(!o.ok)throw new Error(`Code export failed: ${o.status} ${await o.text()}`)}async pollAndDownloadCode(t,n){let i=K({tmsBaseUrl:this.config.tmsBaseUrl,testcaseId:t}),r=this.config.exitTimeoutMs??3e5,o=5e3,s=Date.now()+r;this.log("info","PIPELINE_CODE_EXPORT_POLL","Polling for code export",{url:i,timeout_ms:r});let c=(a,l)=>this.config.authResolver?this.config.authResolver.fetch(a,l):R(a,{...l,headers:{...l?.headers,Authorization:this.buildAuthHeader()}});for(;Date.now()<s;){let a=await c(i,{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"),n("code_export","running","Waiting for code generation\u2026"),await this.sleep(o);continue}let _=u.status.toLowerCase();if(_==="in progress"||_==="in_progress"||_==="pending"){this.log("debug","PIPELINE_CODE_EXPORT_IN_PROGRESS","Code export in progress",{status:u.status}),n("code_export","running","Generating code\u2026"),await this.sleep(o);continue}if(!u.url||u.url.length===0)throw new Error(`Code export status=${u.status} but no files returned`);let p=this.config.codeExportDir??E(this.config.sessionDir,"code-export");F(p,{recursive:!0}),this.log("info","PIPELINE_CODE_EXPORT_DOWNLOAD","Downloading code files",{file_count:u.url.length,dir:p}),n("code_export","running",`Downloading ${u.url.length} files\u2026`);for(let d of u.url){let g=E(p,d.file_name),f=await R(d.file_url);if(!f.ok){this.log("warn","PIPELINE_CODE_EXPORT_FILE_FAILED","Failed to download file",{file_name:d.file_name,status:f.status});continue}let m=await f.text();w(g,m,"utf-8"),this.log("info","PIPELINE_CODE_EXPORT_FILE_SAVED","File saved",{file_name:d.file_name,size_bytes:m.length})}return p}throw new Error("Code export timed out")}sleep(t){return new Promise(n=>setTimeout(n,t))}buildAuthHeader(){return typeof this.config.auth=="string"?`Bearer ${this.config.auth}`:M(this.config.auth.username,this.config.auth.accessKey)}readAuthoredExecution(){let t=this.config.authoredExecutionPath;if(!t)return null;try{let n=L(t,"utf8");return JSON.parse(n),n}catch{return this.log("warn","PIPELINE_AUTHORED_BLOB_UNREADABLE","Authored execution.json missing/unreadable \u2014 pack gets this run's envelope",{path:t}),null}}loadAuthoredBlocks(){let t=this.config.blockAuthoredExecutionPath;if(!t)return[];try{let n=JSON.parse(L(t,"utf8"));return Array.isArray(n.instructions)?n.instructions:[]}catch(n){return this.log("warn","PIPELINE_AUTHORED_BLOB_UNREADABLE","Authored execution.json missing/unreadable \u2014 branches that did not run this time upload empty",{path:t,error:n instanceof Error?n.message:String(n)}),[]}}loadReplayOnlyPassthrough(){let t=this.config.replayOnlyPassthrough;if(!(!t||t.flatIndices.length===0))try{let n=JSON.parse(L(t.authoredExecutionPath,"utf8"));if(!Array.isArray(n.instructions))throw new Error("no instructions array");return{authoredInstructions:n.instructions,replayOnlyFlatIndices:new Set(t.flatIndices)}}catch(n){this.log("warn","PIPELINE_PASSTHROUGH_BLOB_UNREADABLE","Authored execution.json missing/unreadable \u2014 replay-only steps convert from this run's records",{path:t.authoredExecutionPath,flat_indices:t.flatIndices,error:n instanceof Error?n.message:String(n)});return}}buildExecutionEnvelope(t){let n=this.config.runStatuses.every(l=>l==="passed")?"success":"error",i=this.config.variableIds??{},r=[];if(this.config.variables)for(let[l,u]of Object.entries(this.config.variables)){if(u.secret)continue;let _=l.startsWith("global.")?l.slice(7):l;r.push({id:i[_]??0,name:_,value:u.value,session_value:u.value,is_persist:!1,environment_id:0,environment_name:"No Env"})}let o=[],s=l=>{let u=o.find(_=>_.name===l.name);u?u.value=l.value:o.push(l)},c=[],a=new Set;for(let l of this.collectNdjsonPerRun())for(let u of l.records)if(u.output_variable&&u.output_value!=null&&s({name:u.output_variable,value:String(u.output_value),value_type:"test_level",variable_description:"ANALYZE result"}),u.action_type==="upload_files"){let _=N(u.action_params);if(_){let p=_.media_id||_.media_url;if(!a.has(p)){a.add(p),c.push({media_url:_.media_url,media_id:_.media_id,name:_.name,type:_.type});let d=O(_.name);s({name:Q(_.name),value:d,value_type:"string",variable_description:`variable for ${d}`})}}}return{test_id:this.testId,version:"v4",auto_heal_version:this.config.apMode==="v2"?"AH2":"",session_id:this.config.sessionId,org_id:String(this.config.orgId),user_id:String(this.config.userId),url:this.config.firstUrl??"",start_timestamp:this.config.startedAt,end_timestamp:this.config.endedAt,status:n,commit_id:this.config.commitId,instructions:t,modules:[],uploaded_files:c,test_params:[],test_level_variables:JSON.stringify(o),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{ne as a,ie as b,ht as c};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as O,d as S}from"./chunk-K2UEVCIJ.js";import{c as L}from"./chunk-RFHMDQXZ.js";import{n as P,o as R}from"./chunk-RSSOJ3L2.js";import{y as s}from"./chunk-33GXXC2L.js";import{a as y}from"./chunk-HCBYKLMW.js";import{a as E,b as o,i as h}from"./chunk-C44QQJR4.js";import{a as B}from"./chunk-6YGTRKDT.js";import{e as d}from"./chunk-UR6MHSHU.js";var n=d(B(),1);import{basename as D}from"path";var r=d(y(),1),U="evidence-view-server";function Q({packPath:m,viewerBase:w,onDone:V,openUrl:k}){let[t,a]=(0,n.useState)("ask"),[g,b]=(0,n.useState)(null),[l,p]=(0,n.useState)(null),f=(0,n.useRef)(null),u=(0,n.useRef)(!1),x=async()=>{let e=f.current;f.current=null,e&&(R(U),await e.close())},v=()=>{u.current||(u.current=!0,V())};return h((e,i)=>{u.current||(t==="ask"?e==="y"||e==="Y"?a("starting"):(e==="n"||e==="N"||i.return||i.escape)&&v():t==="serving"&&(e==="q"||e==="Q"||i.escape)&&x().then(v))}),(0,n.useEffect)(()=>{if(t!=="starting")return;let e=!1;return(async()=>{try{let i=D(m),c=await O({packs:new Map([[i,m]]),allowedOrigins:[new URL(w).origin]});if(e){await c.close();return}f.current=c,P(U,()=>{c.close()});let T=S(c.urlFor(i),w);b(T);try{await(k??(q=>L(q)))(T)}catch{p("could not open browser \u2014 open the URL manually")}a("serving")}catch(i){p(`evidence view failed \u2014 ${i.message}`),a("failed")}})(),()=>{e=!0}},[t]),(0,n.useEffect)(()=>{if(t!=="failed")return;let e=setTimeout(v,0);return()=>clearTimeout(e)},[t]),(0,n.useEffect)(()=>()=>{x()},[]),t==="ask"?(0,r.jsxs)(o,{children:["View evidence in browser? ",(0,r.jsx)(o,{color:s.dim,children:"(y/N)"})]}):t==="serving"||t==="starting"?(0,r.jsxs)(E,{flexDirection:"column",children:[g?(0,r.jsxs)(o,{children:["viewer ",(0,r.jsx)(o,{color:s.orange,children:g})]}):(0,r.jsx)(o,{color:s.dim,children:"starting\u2026"}),l?(0,r.jsx)(o,{color:"yellow",children:l}):null,t==="serving"?(0,r.jsx)(o,{color:s.dim,children:"Press q when done"}):null]}):l?(0,r.jsx)(o,{color:"yellow",children:l}):null}export{Q as a};
2
+ import{b as O,d as S}from"./chunk-VNFCX2SH.js";import{c as L}from"./chunk-RFHMDQXZ.js";import{n as P,o as R}from"./chunk-RSSOJ3L2.js";import{y as s}from"./chunk-B2ZGG7WM.js";import{a as y}from"./chunk-HCBYKLMW.js";import{a as E,b as o,i as h}from"./chunk-C44QQJR4.js";import{a as B}from"./chunk-6YGTRKDT.js";import{e as d}from"./chunk-UR6MHSHU.js";var n=d(B(),1);import{basename as D}from"path";var r=d(y(),1),U="evidence-view-server";function Q({packPath:m,viewerBase:w,onDone:V,openUrl:k}){let[t,a]=(0,n.useState)("ask"),[g,b]=(0,n.useState)(null),[l,p]=(0,n.useState)(null),f=(0,n.useRef)(null),u=(0,n.useRef)(!1),x=async()=>{let e=f.current;f.current=null,e&&(R(U),await e.close())},v=()=>{u.current||(u.current=!0,V())};return h((e,i)=>{u.current||(t==="ask"?e==="y"||e==="Y"?a("starting"):(e==="n"||e==="N"||i.return||i.escape)&&v():t==="serving"&&(e==="q"||e==="Q"||i.escape)&&x().then(v))}),(0,n.useEffect)(()=>{if(t!=="starting")return;let e=!1;return(async()=>{try{let i=D(m),c=await O({packs:new Map([[i,m]]),allowedOrigins:[new URL(w).origin]});if(e){await c.close();return}f.current=c,P(U,()=>{c.close()});let T=S(c.urlFor(i),w);b(T);try{await(k??(q=>L(q)))(T)}catch{p("could not open browser \u2014 open the URL manually")}a("serving")}catch(i){p(`evidence view failed \u2014 ${i.message}`),a("failed")}})(),()=>{e=!0}},[t]),(0,n.useEffect)(()=>{if(t!=="failed")return;let e=setTimeout(v,0);return()=>clearTimeout(e)},[t]),(0,n.useEffect)(()=>()=>{x()},[]),t==="ask"?(0,r.jsxs)(o,{children:["View evidence in browser? ",(0,r.jsx)(o,{color:s.dim,children:"(y/N)"})]}):t==="serving"||t==="starting"?(0,r.jsxs)(E,{flexDirection:"column",children:[g?(0,r.jsxs)(o,{children:["viewer ",(0,r.jsx)(o,{color:s.orange,children:g})]}):(0,r.jsx)(o,{color:s.dim,children:"starting\u2026"}),l?(0,r.jsx)(o,{color:"yellow",children:l}):null,t==="serving"?(0,r.jsx)(o,{color:s.dim,children:"Press q when done"}):null]}):l?(0,r.jsx)(o,{color:"yellow",children:l}):null}export{Q as a};