@testmuai/kane-cli 0.8.10 → 0.8.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (231) hide show
  1. package/dist/{ChatSurface-OWGOCHG3.js → ChatSurface-YFJDAXOG.js} +1 -1
  2. package/dist/{ChromeProfilePicker-QIMCWPPI.js → ChromeProfilePicker-PUCZN6WU.js} +1 -1
  3. package/dist/{CliFeedbackPrompt-34E2AXS4.js → CliFeedbackPrompt-JAIB5MHS.js} +1 -1
  4. package/dist/{CliUploadProgress-TRKOSED7.js → CliUploadProgress-53LQMQJD.js} +1 -1
  5. package/dist/{ConfigView-XVKR7ATN.js → ConfigView-7HFP4OXS.js} +1 -1
  6. package/dist/EvidenceViewOffer-2T2ZGHIF.js +2 -0
  7. package/dist/FolderPicker-LTQW4YNR.js +2 -0
  8. package/dist/{InfoBox-QM5YEBMH.js → InfoBox-62YG3YNQ.js} +1 -1
  9. package/dist/{LinksBox-CSEDEZGU.js → LinksBox-6NS3GHWO.js} +1 -1
  10. package/dist/{ProfilesView-CZVPREIS.js → ProfilesView-HIKK2HPC.js} +1 -1
  11. package/dist/{ProjectPicker-F6FEWNMY.js → ProjectPicker-2CJMO5TD.js} +1 -1
  12. package/dist/{SaveSessionPrompt-RUSFOLBZ.js → SaveSessionPrompt-4DTPZSXD.js} +1 -1
  13. package/dist/SingleShotApp-KXZF5ZJM.js +2 -0
  14. package/dist/{SummaryBox-KOJXTZVZ.js → SummaryBox-A6LKKQXJ.js} +1 -1
  15. package/dist/TestMdRunView-6X6W5YAP.js +2 -0
  16. package/dist/{TestrunEvidenceTable-KGVBX76H.js → TestrunEvidenceTable-7SCCTZPH.js} +1 -1
  17. package/dist/{WhoamiView-IOTBOCGK.js → WhoamiView-PDMQ6F5N.js} +1 -1
  18. package/dist/{app-download-7AF6QL2C.js → app-download-K2ELUXWR.js} +1 -1
  19. package/dist/{auth-2HTDCT7X.js → auth-5WJSFLCP.js} +1 -1
  20. package/dist/{binary-NKX3NEK7.js → binary-QVQRWQFK.js} +1 -1
  21. package/dist/{bind-IMBQFRKT.js → bind-5WELCZ4S.js} +3 -3
  22. package/dist/{bootstrap-TNFANHSS.js → bootstrap-3LNHRDQH.js} +1 -1
  23. package/dist/bridge-WFSSMJ57.js +2 -0
  24. package/dist/{changelog-SQVLSCYO.js → changelog-TK6DWFVW.js} +1 -1
  25. package/dist/{chat-committer-K3NOTLOU.js → chat-committer-MAW25ICC.js} +1 -1
  26. package/dist/chat-controller-6GW2HSJP.js +2 -0
  27. package/dist/{chunk-EH3YMGQ7.js → chunk-2E55VQYA.js} +1 -1
  28. package/dist/{chunk-PCVTSFIX.js → chunk-2KQF6WLX.js} +4 -4
  29. package/dist/{chunk-5EKTQY2S.js → chunk-2QSG5ZG6.js} +1 -1
  30. package/dist/{chunk-BG2AZQLI.js → chunk-2ZBY2GME.js} +1 -1
  31. package/dist/{chunk-54JZ6VEW.js → chunk-3D7VYEDP.js} +1 -1
  32. package/dist/{chunk-LTNMOEHT.js → chunk-3FJNTRAS.js} +1 -1
  33. package/dist/{chunk-HE3ZKFRC.js → chunk-3PMEHGH3.js} +1 -1
  34. package/dist/chunk-47WY2637.js +84 -0
  35. package/dist/{chunk-YUA2VDWH.js → chunk-4AZ7IG2A.js} +1 -1
  36. package/dist/{chunk-HNNVVK2O.js → chunk-4FXSDPQW.js} +1 -1
  37. package/dist/{chunk-ZXTVP4WX.js → chunk-4SXJKDHO.js} +2 -2
  38. package/dist/{chunk-6S3Z3WPF.js → chunk-4VYWTTT4.js} +2 -2
  39. package/dist/{chunk-XTUSDGAB.js → chunk-4VZRBBLF.js} +1 -1
  40. package/dist/{chunk-SAFETUCL.js → chunk-5LEO463W.js} +1 -1
  41. package/dist/{chunk-KUAFVRSR.js → chunk-5NBT5IVT.js} +1 -1
  42. package/dist/{chunk-ZFZB4CGJ.js → chunk-6DOS5CJ5.js} +1 -1
  43. package/dist/{chunk-N7Z7BQYO.js → chunk-6GH4DRKR.js} +1 -1
  44. package/dist/{chunk-RP7FW23G.js → chunk-7B7OSHPX.js} +1 -1
  45. package/dist/{chunk-NJQNHD5P.js → chunk-7HUJVIMO.js} +1 -1
  46. package/dist/{chunk-2ULZVQZV.js → chunk-7KRCBN6X.js} +1 -1
  47. package/dist/{chunk-USUFF3S6.js → chunk-7P3JGF2X.js} +1 -1
  48. package/dist/{chunk-WAI5UHW3.js → chunk-A4BDLZOD.js} +1 -1
  49. package/dist/{chunk-LUTRUSIV.js → chunk-A76UL3EN.js} +1 -1
  50. package/dist/{chunk-YXPWGIQ2.js → chunk-ASK4AZFC.js} +1 -1
  51. package/dist/{chunk-RJ4YFH7K.js → chunk-AXW3WDFO.js} +1 -1
  52. package/dist/{chunk-IVQX3AKL.js → chunk-B7K5WOOU.js} +1 -1
  53. package/dist/{chunk-P3UGM74Z.js → chunk-B7TJIUKZ.js} +1 -1
  54. package/dist/{chunk-FOP6CJAM.js → chunk-BE4FBVKY.js} +1 -1
  55. package/dist/chunk-BHSHGWBL.js +2 -0
  56. package/dist/chunk-CABRAZOL.js +5 -0
  57. package/dist/{chunk-W7PBJXLJ.js → chunk-CBLUNSF4.js} +1 -1
  58. package/dist/{chunk-5Q3W3SX7.js → chunk-CL3AMEK6.js} +1 -1
  59. package/dist/{chunk-ZDAO5D6D.js → chunk-CQKKDIKA.js} +1 -1
  60. package/dist/{chunk-2BIPFAGX.js → chunk-CRPBARFG.js} +1 -1
  61. package/dist/{chunk-WEJA3EVI.js → chunk-DEUDRSU7.js} +1 -1
  62. package/dist/{chunk-GHL2A273.js → chunk-DHWS7SLT.js} +2 -2
  63. package/dist/{chunk-NYQOYOBA.js → chunk-DJJO4IHY.js} +1 -1
  64. package/dist/{chunk-C33E5XQM.js → chunk-DLJIML73.js} +1 -1
  65. package/dist/{chunk-EV64VI66.js → chunk-DP7GPS6S.js} +1 -1
  66. package/dist/chunk-F7R6A6P5.js +4 -0
  67. package/dist/{chunk-EKOL4WCC.js → chunk-FIODM24X.js} +1 -1
  68. package/dist/{chunk-SU3QKERU.js → chunk-FQRWYXFG.js} +1 -1
  69. package/dist/{chunk-6FCPS2VT.js → chunk-FYLMTZ3J.js} +1 -1
  70. package/dist/{chunk-YHL5NA43.js → chunk-G5ZGEZCA.js} +1 -1
  71. package/dist/{chunk-AWEUKXZQ.js → chunk-GMXM4WHF.js} +1 -1
  72. package/dist/{chunk-CSCJLGIY.js → chunk-GSNGC7HI.js} +1 -1
  73. package/dist/{chunk-HXSOZWFL.js → chunk-GV5BX2IQ.js} +1 -1
  74. package/dist/{chunk-5YBKKWJA.js → chunk-HFRMJP2P.js} +1 -1
  75. package/dist/chunk-HJBORIFP.js +26 -0
  76. package/dist/{chunk-WIAZN7G4.js → chunk-HULEZ3D3.js} +1 -1
  77. package/dist/{chunk-NDKHC6KL.js → chunk-IX4FH5W6.js} +1 -1
  78. package/dist/{chunk-CKNVMB4E.js → chunk-JAO7TZBV.js} +1 -1
  79. package/dist/{chunk-LKUWEQ5M.js → chunk-JJJREAFQ.js} +1 -1
  80. package/dist/{chunk-ESHDTCSZ.js → chunk-K6BWPGBO.js} +1 -1
  81. package/dist/chunk-KRL2BDI5.js +8 -0
  82. package/dist/{chunk-ML2E3JGK.js → chunk-M3Q7IQMS.js} +1 -1
  83. package/dist/{chunk-FH6EDP77.js → chunk-M7CGNE2D.js} +4 -4
  84. package/dist/{chunk-M6SFFAAQ.js → chunk-NBXYL2JT.js} +6 -6
  85. package/dist/chunk-NGASEXVA.js +27 -0
  86. package/dist/{chunk-WXJQDLXX.js → chunk-NLSR2IFN.js} +1 -1
  87. package/dist/{chunk-H4WIA4IP.js → chunk-NP3VGFZM.js} +1 -1
  88. package/dist/{chunk-BUM367KV.js → chunk-NVRXDLJN.js} +1 -1
  89. package/dist/{chunk-SAKUG4KE.js → chunk-NYUMJDCE.js} +1 -1
  90. package/dist/chunk-O7RB4X6I.js +21 -0
  91. package/dist/{chunk-QJNQN6ND.js → chunk-OC7TJTQG.js} +1 -1
  92. package/dist/{chunk-GOF5PQ5T.js → chunk-OGJ6ZSLC.js} +1 -1
  93. package/dist/{chunk-EEFZXZTZ.js → chunk-OKBEMFAW.js} +1 -1
  94. package/dist/{chunk-CXKWVHZK.js → chunk-OKCULEBD.js} +1 -1
  95. package/dist/{chunk-XMTSHHYQ.js → chunk-OXHMUZJV.js} +1 -1
  96. package/dist/chunk-OZMYKG6E.js +6 -0
  97. package/dist/{chunk-5G22NOZK.js → chunk-QHSF2CXK.js} +1 -1
  98. package/dist/{chunk-BZCVLCMG.js → chunk-QIRZBOKA.js} +1 -1
  99. package/dist/{chunk-W3Z7AZNT.js → chunk-R4EGL7VM.js} +1 -1
  100. package/dist/{chunk-KAZGHWGK.js → chunk-S63XGGBE.js} +1 -1
  101. package/dist/{chunk-JGZWR3CR.js → chunk-SNKFWPEM.js} +2 -2
  102. package/dist/chunk-T4OJX2GZ.js +15 -0
  103. package/dist/chunk-TB2CCKL7.js +2 -0
  104. package/dist/{chunk-TI7MR3PB.js → chunk-TSW5A7W3.js} +1 -1
  105. package/dist/{chunk-UH2ZTX4E.js → chunk-TYRTD5DD.js} +1 -1
  106. package/dist/{chunk-RSNG5PBN.js → chunk-URLZULC7.js} +1 -1
  107. package/dist/{chunk-BQSLPF5M.js → chunk-VGLY4HWA.js} +1 -1
  108. package/dist/{chunk-D6566A2X.js → chunk-VUOAFV27.js} +1 -1
  109. package/dist/{chunk-WAWMIKSI.js → chunk-W4IRHQGO.js} +9 -9
  110. package/dist/{chunk-OSRRMY6M.js → chunk-W7NI6JCF.js} +1 -1
  111. package/dist/chunk-WD52ZNQY.js +2 -0
  112. package/dist/chunk-WRVDIZAI.js +6 -0
  113. package/dist/{chunk-PMOUXVUC.js → chunk-X6WB2QTT.js} +1 -1
  114. package/dist/{chunk-B4CYIZP5.js → chunk-XB7EMX6J.js} +1 -1
  115. package/dist/{chunk-KRKGZ2ZW.js → chunk-XS2LZFCH.js} +1 -1
  116. package/dist/{chunk-UEANTGQS.js → chunk-XYSFPVJX.js} +1 -1
  117. package/dist/{chunk-47OUD76M.js → chunk-Y4ODYIOP.js} +1 -1
  118. package/dist/{chunk-O5U6EAL3.js → chunk-YELGHSVH.js} +1 -1
  119. package/dist/{chunk-DF3DUGJS.js → chunk-YQ4MRF57.js} +4 -4
  120. package/dist/{chunk-NYSFEZUR.js → chunk-YSNBXUM6.js} +1 -1
  121. package/dist/{chunk-KGKJU27A.js → chunk-Z4QLCWLB.js} +1 -1
  122. package/dist/{chunk-SXX7ZE6L.js → chunk-Z6GMZOVL.js} +3 -3
  123. package/dist/{chunk-IWVA37B6.js → chunk-ZES42R57.js} +1 -1
  124. package/dist/{chunk-ETIQJIDI.js → chunk-ZMJD3CI7.js} +1 -1
  125. package/dist/{committer-C6UCDYMC.js → committer-42AFWMEX.js} +1 -1
  126. package/dist/{config-UF635MC4.js → config-KU2UICMC.js} +1 -1
  127. package/dist/{cover-cmd-5LPHIOSI.js → cover-cmd-HAOBK2IC.js} +1 -1
  128. package/dist/{credentials-3KBLEVJH.js → credentials-BEC4I5SE.js} +1 -1
  129. package/dist/{deps-bundle-WGF4YYGO.js → deps-bundle-EY5T7OH3.js} +1 -1
  130. package/dist/{deps-resolve-DVJPU4YX.js → deps-resolve-MPLFFCZZ.js} +1 -1
  131. package/dist/design-committer-2BQVZPO4.js +2 -0
  132. package/dist/dispatch-NE35HS5F.js +2 -0
  133. package/dist/{doctor-2KRK42L2.js → doctor-JBXA6WNL.js} +1 -1
  134. package/dist/{docx-convert-JMUMT5C4.js → docx-convert-BIV5T7F5.js} +1 -1
  135. package/dist/{dossier-Y6TJWFZU.js → dossier-WSWXZAPL.js} +1 -1
  136. package/dist/effective-decisions-UNE2TFVA.js +2 -0
  137. package/dist/{evidence-CDCFEYS7.js → evidence-MJV3PY2J.js} +1 -1
  138. package/dist/evolve-cmd-I4Z6IPIM.js +2 -0
  139. package/dist/explain-O3A2HZWD.js +2 -0
  140. package/dist/{explain-cmd-RMJPXD4U.js → explain-cmd-BXFR5DB6.js} +1 -1
  141. package/dist/{explain-cmd-XCRO4AS6.js → explain-cmd-IRQ2YX5L.js} +1 -1
  142. package/dist/{extract-bind-VFQWACVO.js → extract-bind-PPMY4FFA.js} +3 -3
  143. package/dist/{extract-cmd-2OFQBBJ4.js → extract-cmd-RHVLPNQB.js} +2 -2
  144. package/dist/{feeder-IOR3XRNF.js → feeder-52VBZY3R.js} +1 -1
  145. package/dist/{gaps-cmd-JIUM5YDY.js → gaps-cmd-MSDGU6OU.js} +1 -1
  146. package/dist/{generate-headless-B35UUR5A.js → generate-headless-NSK32S53.js} +2 -2
  147. package/dist/index.js +115 -115
  148. package/dist/ingest-WTPY2VLS.js +2 -0
  149. package/dist/ingest-cmd-GOPW3SNF.js +2 -0
  150. package/dist/install-BDHZVEY4.js +2 -0
  151. package/dist/{interactive-bind-OWASLPBQ.js → interactive-bind-4FNW3OYT.js} +4 -4
  152. package/dist/{lifecycle-cmd-KSMETBPP.js → lifecycle-cmd-HYNG5KH6.js} +1 -1
  153. package/dist/{list-cmd-V3HJ5K4O.js → list-cmd-Y4WEOT3E.js} +1 -1
  154. package/dist/{list-commands-SLQDF6AT.js → list-commands-CJCEW7MQ.js} +1 -1
  155. package/dist/{logical-ids-MLXAH45L.js → logical-ids-N3UZACB4.js} +1 -1
  156. package/dist/login-flow-DLG2WHSZ.js +2 -0
  157. package/dist/{maintenance-cmd-VFYGKY3X.js → maintenance-cmd-UJNH47SG.js} +1 -1
  158. package/dist/{mobile-prompts-6MGOXIKX.js → mobile-prompts-SJZVJWSB.js} +1 -1
  159. package/dist/persist-recorded-session-FWBAOQEF.js +3 -0
  160. package/dist/{phase-seed-BMOSAA74.js → phase-seed-2WI7KUYO.js} +1 -1
  161. package/dist/pipeline-B2TYZBMB.js +2 -0
  162. package/dist/prepare-target-JGVB7OKC.js +2 -0
  163. package/dist/readmodel-YDLGQDMH.js +2 -0
  164. package/dist/reconcile-cmd-6ILIXD3U.js +2 -0
  165. package/dist/{reconcile-deps-RYO67ZXY.js → reconcile-deps-GMQA6ULT.js} +2 -2
  166. package/dist/{reconcile-engine-PRH6YIAZ.js → reconcile-engine-XLLYS5ZB.js} +1 -1
  167. package/dist/{recording-banner-CH2SZ4IU.js → recording-banner-CQBXZMT3.js} +1 -1
  168. package/dist/{records-JLS63SDI.js → records-EW4PIJ5W.js} +1 -1
  169. package/dist/registry-AA5YIO5Y.js +2 -0
  170. package/dist/{replay-policy-CVQ6OJX5.js → replay-policy-A62KXE6Y.js} +1 -1
  171. package/dist/{require-project-folder-XY77JKAQ.js → require-project-folder-K3E3QIOZ.js} +1 -1
  172. package/dist/{resolve-run-intent-JFIGIF72.js → resolve-run-intent-3CENNCF3.js} +1 -1
  173. package/dist/{resolver-6VDNZ6KP.js → resolver-PSNP72H4.js} +1 -1
  174. package/dist/{revert-PRR3D4XM.js → revert-RXHWWUMQ.js} +1 -1
  175. package/dist/{review-cmd-SAGIKWEW.js → review-cmd-JUOWTME4.js} +1 -1
  176. package/dist/run-6CMGGU2W.js +2 -0
  177. package/dist/run-PZIYMD35.js +2 -0
  178. package/dist/{run-test-md-OLGWTC4I.js → run-test-md-XBM6RMCI.js} +2 -2
  179. package/dist/{sessions-cmd-VDQGRBEM.js → sessions-cmd-PGE6LP2W.js} +1 -1
  180. package/dist/{skill-installer-NT7ZT6O4.js → skill-installer-FBOPYFYS.js} +1 -1
  181. package/dist/{spawner-YQSAPZR4.js → spawner-URQ5OAY7.js} +1 -1
  182. package/dist/{structured-answers-YAVW65G4.js → structured-answers-BZWJUX22.js} +1 -1
  183. package/dist/tcg-generate-BPLQ7WJ5.js +2 -0
  184. package/dist/testmd-actions-WJS2YM7B.js +2 -0
  185. package/dist/testmd-sync-TPUBEORI.js +2 -0
  186. package/dist/token-refresh-IT4LVE2H.js +2 -0
  187. package/dist/{validate-basic-OMAFYHME.js → validate-basic-BXBHTTTO.js} +1 -1
  188. package/dist/verdicts-J5MJHUGG.js +2 -0
  189. package/dist/{version-check-FRVZSYNF.js → version-check-BGHE3LAK.js} +1 -1
  190. package/dist/{view-cmd-SXXNDZIC.js → view-cmd-XD5ENSML.js} +1 -1
  191. package/dist/{walk-session-LNFOCPJ6.js → walk-session-EYBUURRA.js} +1 -1
  192. package/dist/{with-telemetry-4ATZC6IR.js → with-telemetry-L3SO6J3L.js} +1 -1
  193. package/package.json +11 -11
  194. package/dist/EvidenceViewOffer-M2TGMSNE.js +0 -2
  195. package/dist/FolderPicker-WZTNQ5IV.js +0 -2
  196. package/dist/SingleShotApp-WBFVUZFP.js +0 -2
  197. package/dist/TestMdRunView-BEXL7TIN.js +0 -2
  198. package/dist/bridge-SXYWYZDO.js +0 -2
  199. package/dist/chat-controller-YJCNU76T.js +0 -2
  200. package/dist/chunk-724NYDMU.js +0 -27
  201. package/dist/chunk-CPGUTSUD.js +0 -6
  202. package/dist/chunk-EKCGZXZE.js +0 -2
  203. package/dist/chunk-I3OVXNBW.js +0 -7
  204. package/dist/chunk-I5KYZHJ5.js +0 -71
  205. package/dist/chunk-IPEA7ZOF.js +0 -8
  206. package/dist/chunk-SXUQBPQ6.js +0 -2
  207. package/dist/chunk-TGPI7VDR.js +0 -21
  208. package/dist/chunk-VIJUT5AR.js +0 -26
  209. package/dist/chunk-WHEWZR2C.js +0 -15
  210. package/dist/chunk-XIGTZTFP.js +0 -5
  211. package/dist/design-committer-UPC6NZUF.js +0 -2
  212. package/dist/dispatch-YTIJKX6C.js +0 -2
  213. package/dist/effective-decisions-DRM3JSR4.js +0 -2
  214. package/dist/evolve-cmd-L3JIBYP5.js +0 -2
  215. package/dist/explain-3HAZY7Q6.js +0 -2
  216. package/dist/ingest-TTUQ7UDK.js +0 -2
  217. package/dist/ingest-cmd-LAUSXSI3.js +0 -2
  218. package/dist/install-ENSOEMSX.js +0 -2
  219. package/dist/login-flow-YKQUXP75.js +0 -2
  220. package/dist/persist-recorded-session-RKG7HOEW.js +0 -3
  221. package/dist/pipeline-M25AR7RM.js +0 -2
  222. package/dist/prepare-target-UGACDQEJ.js +0 -2
  223. package/dist/readmodel-TDRFVDVI.js +0 -2
  224. package/dist/reconcile-cmd-MR2MSVZ5.js +0 -2
  225. package/dist/registry-ARR5ITIQ.js +0 -2
  226. package/dist/run-GTBYWSLW.js +0 -2
  227. package/dist/run-UETW72YU.js +0 -2
  228. package/dist/tcg-generate-D73BMKOE.js +0 -2
  229. package/dist/testmd-actions-XPYXS36F.js +0 -2
  230. package/dist/token-refresh-2XVSIFRM.js +0 -2
  231. package/dist/verdicts-KEBSV2NL.js +0 -2
@@ -1,4 +1,4 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as be}from"./chunk-JQW2QFSX.js";import{a as xe,b as Re}from"./chunk-6FCPS2VT.js";import{a as se,b as q,d as ue}from"./chunk-UH2ZTX4E.js";import{a as Ne,b as Ee,g as le,j as ee}from"./chunk-XMTSHHYQ.js";import{d as te,e as w,f as re,g as oe,h as de}from"./chunk-AKX4VRRR.js";function Me(r,s){let t=r.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");if(t.length>60){let o=t.lastIndexOf("-",60);t=(o>0?t.slice(0,o):t.slice(0,60)).replace(/-+$/g,"")}if(!ae.test(t))return null;let e=t;for(let o=2;s(e);o++)e=`${t}-${o}`;return ae.test(e)?e:null}var Ve={source:"src",usecase:"uc",scenario:"sc",ac:"ac",test:"t",gap:"gap",stylenote:"sty"};function ze(r,s,t){let e=Ve[r];return Me(e?`${e} ${s}`:s,t)}var Pe={usecase:"uc",scenario:"sc",ac:"ac",test:"t",gap:"gap",stylenote:"sty"},Oe=/^(uc|sc|ac|t|gap|sty)-\d+$/i;function we(r,s,t){let e=Pe[r];if(!e)return null;let o=new RegExp(`^${e}-(\\d+)$`),d=0;for(let p of t){let l=o.exec(p);if(!l)continue;let n=Number(l[1]);Number.isSafeInteger(n)&&n>d&&(d=n)}let c=d+1;for(;s(`${e}-${c}`);)c+=1;return`${e}-${c}`}var Le=/^L([1-9]\d*)-L([1-9]\d*)$/,Ge=/^img#(p[1-9]\d*-[1-9]\d*|i[1-9]\d*)$/;function pe(r){if(r==="img#whole")return{kind:"img-whole"};let s=Ge.exec(r);if(s)return{kind:"img-part",ref:s[1]};let t=Le.exec(r);return t?{kind:"lines",a:parseInt(t[1],10),b:parseInt(t[2],10)}:null}function Ue(r,s){let t=/^L(\d+)-L(\d+)$/.exec(s);if(!t)return null;let e=parseInt(t[1],10),o=parseInt(t[2],10),d=r.split(`
2
+ import{a as be}from"./chunk-JQW2QFSX.js";import{a as xe,b as Re}from"./chunk-FYLMTZ3J.js";import{a as se,b as q,d as ue}from"./chunk-TYRTD5DD.js";import{a as Ne,b as Ee,g as le,j as ee}from"./chunk-OXHMUZJV.js";import{d as te,e as w,f as re,g as oe,h as de}from"./chunk-AKX4VRRR.js";function Me(r,s){let t=r.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");if(t.length>60){let o=t.lastIndexOf("-",60);t=(o>0?t.slice(0,o):t.slice(0,60)).replace(/-+$/g,"")}if(!ae.test(t))return null;let e=t;for(let o=2;s(e);o++)e=`${t}-${o}`;return ae.test(e)?e:null}var Ve={source:"src",usecase:"uc",scenario:"sc",ac:"ac",test:"t",gap:"gap",stylenote:"sty"};function ze(r,s,t){let e=Ve[r];return Me(e?`${e} ${s}`:s,t)}var Pe={usecase:"uc",scenario:"sc",ac:"ac",test:"t",gap:"gap",stylenote:"sty"},Oe=/^(uc|sc|ac|t|gap|sty)-\d+$/i;function we(r,s,t){let e=Pe[r];if(!e)return null;let o=new RegExp(`^${e}-(\\d+)$`),d=0;for(let p of t){let l=o.exec(p);if(!l)continue;let n=Number(l[1]);Number.isSafeInteger(n)&&n>d&&(d=n)}let c=d+1;for(;s(`${e}-${c}`);)c+=1;return`${e}-${c}`}var Le=/^L([1-9]\d*)-L([1-9]\d*)$/,Ge=/^img#(p[1-9]\d*-[1-9]\d*|i[1-9]\d*)$/;function pe(r){if(r==="img#whole")return{kind:"img-whole"};let s=Ge.exec(r);if(s)return{kind:"img-part",ref:s[1]};let t=Le.exec(r);return t?{kind:"lines",a:parseInt(t[1],10),b:parseInt(t[2],10)}:null}function Ue(r,s){let t=/^L(\d+)-L(\d+)$/.exec(s);if(!t)return null;let e=parseInt(t[1],10),o=parseInt(t[2],10),d=r.split(`
3
3
  `);return e<1||o<e||o>d.length?null:d.slice(e-1,o).map(c=>c.replace(/^\d+\| /,"")).join(`
4
4
  `)}function Te(r,s,t){let e=pe(s.anchor);if(r.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((r.images??[]).map(c=>c.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 o=t!==null?Ue(t,s.anchor):null;return o===null?[{code:"BAD_ANCHOR",detail:`anchor ${s.anchor} does not resolve in the source`}]:o.includes(s.quote)?[]:[{code:"QUOTE_MISMATCH",detail:`quote is not verbatim within ${s.anchor}`}]}import{existsSync as Fe,readFileSync as He}from"fs";function dt(r){let s=Re(r),t=new Map(Object.entries(s.heads)),e=new Map(Object.entries(s.trust)),o=new Map(Object.entries(s.nodeLabel)),d=new Map(Object.entries(s.superseded)),c=new Map(Object.entries(s.names)),p=new Map(Object.entries(s.archivedReason)),l=new Set(s.appliedEvents),n=new Map(Object.entries(s.conv)),m=g=>s.media[g]??{format:"text",media_type:"text/plain",anchors_supported:["L-L"]},f=new Map;for(let[g,_]of c)f.set(_,g);let a=new Map,S=g=>{if(a.has(g))return a.get(g);if(!o.has(g))return a.set(g,null),null;let _=xe(r,g);if(!Fe(_))throw new Ne(`derived node file missing for ${g} \u2014 run kane-cli context rebuild`);let I=JSON.parse(He(_,"utf8"));return a.set(g,I),I},v=g=>{let _=g,I=new Set;for(;d.has(_)&&!I.has(_);){I.add(_);let O=d.get(_);if(typeof O!="string")break;_=O}return _},N=null,y=g=>{let _=f.get(g);if(_!==void 0)return _;if(N===null){N=new Map;for(let[G,D]of d)typeof D=="string"&&N.set(D,G)}let I=new Set,O=g;for(;!I.has(O);){I.add(O);let G=N.get(O);if(G===void 0)return null;let D=f.get(G);if(D!==void 0)return D;O=G}return null},b=g=>{Oe.test(g)&&(g=g.toLowerCase());let _=t.get(g),I=o.has(g)?g:c.get(g)??(typeof _=="string"?_:void 0);if(I===void 0||!o.has(I))return null;let O=v(I);return{cid:I,tip:O,superseded:d.has(I)||d.has(O)}},V=new Map;for(let g of Object.values(s.forward))for(let _ of g){let I=V.get(_.dst);I?I.push(_):V.set(_.dst,[_])}let A=g=>(g??[]).filter(_=>!d.has(_.ecid)),K=g=>A(V.get(g)),P=g=>K(g).filter(_=>_.type===w.DERIVES),J=g=>A(s.forward[g]).some(_=>oe(_.type)?.pin?.comparesTo==="dst_tip"&&d.has(_.dst)),ie=g=>{if(d.has(g))return"superseded";let _=P(g);if(_.length===0)return J(g)?"stale":"fresh";let I=new Map;for(let D of _)I.set(D.props.source_id,D);let O=!1,G=!1;for(let[D,k]of I){let U=t.get(D);if(U!=null&&(O=!0,U!==k.props.source_cid)){let i=n.get(D)?.chain;(!i||!i.includes(k.props.source_cid))&&(G=!0)}}return O?G||J(g)?"stale":"fresh":"orphaned"};return{heads:t,trust:e,nodeLabel:o,superseded:d,names:c,nameOf:f,archivedReason:p,appliedEvents:l,convChains:n,mediaOf:m,extractedSourceCids:new Set(s.extracted),extractionCompleteness:new Map(Object.entries(s.completeness??{}).map(([g,{seq:_,...I}])=>[g,I])),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:g=>o.has(g),getNode:S,byLabel:g=>[...o.entries()].filter(([,_])=>_===g).map(([_])=>({cid:_,content:S(_)?.content??{}})),edgesFrom:g=>A(s.forward[g]),edgesInto:K,derivesInto:P,resolve:b,tipOf:v,displayNameOf:y,stale:ie,staleList:()=>[...o.keys()].map(g=>({cid:g,state:ie(g)})).filter(g=>g.state!=="fresh"),execHistory:g=>{let _=b(g);if(!_)return[];let I=v(_.cid),O=new Set([I]),G=!0;for(;G;){G=!1;for(let[k,U]of d)U!==null&&O.has(U)&&!O.has(k)&&(O.add(k),G=!0)}let D=[];for(let k of Object.entries(s.exec??{}))O.has(k[0])&&D.push(...k[1]);return D.sort((k,U)=>k.started_at<U.started_at?-1:1)},retractedEdgesTouching:g=>{let _=new Set([v(g),g]),I=!0;for(;I;){I=!1;for(let[k,U]of d)typeof U=="string"&&_.has(U)&&!_.has(k)&&(_.add(k),I=!0)}let O=s.edgeRetractions??{},G=[],D=new Set;for(let k of _)for(let U of[...s.forward[k]??[],...V.get(k)??[]]){let i=O[U.ecid];!i||D.has(U.ecid)||(D.add(U.ecid),G.push({...U,retraction:i}))}return G}}}function at(r,s){if(r.stale(s)!=="stale")return!1;let t=new Map;for(let e of r.derivesInto(s))t.set(e.props.source_id,e);for(let[e,o]of t){let d=r.heads.get(e);if(d==null||d===o.props.source_cid)continue;let c=r.convChains.get(e)?.chain;if(!c||!c.includes(o.props.source_cid))return!0}for(let e of r.edgesFrom(s)){if(oe(e.type)?.pin?.comparesTo!=="dst_tip"||!r.superseded.has(e.dst))continue;let o=r.tipOf(e.dst);if(r.superseded.has(o)||r.nodeLabel.get(o)==="usecase")return!0}return!1}function fe(r,s){let t=new Map;for(let[c,p]of r.superseded)typeof p=="string"&&p!==c&&t.set(p,[...t.get(p)??[],c]);let e=[],o=[s],d=new Set;for(;o.length>0;){let c=o.pop();d.has(c)||(d.add(c),e.push(c),o.push(...t.get(c)??[]))}return e}function je(r,s){return(r.extraction_claims??[]).some(t=>t.source_id===s&&t.completeness==="complete")}function qe(r,s){let t=new Set;for(let e of fe(r,s))for(let o of r.derivesInto(e))t.add(o.props?.source_id??"conversation");return t}function ve(r,s){let t=[],e=[],o=r.archived??[];if(o.length===0)return{valid:t,errors:e};let d=new Set([...r.source?[r.source.source_id]:[],...(r.sources??[]).map(p=>p.source_id)]),c=new Set;for(let p of r.use_cases){if(!p.matches_existing)continue;let l=s.resolve(p.matches_existing.cid);l&&c.add(s.tipOf(l.cid))}for(let p of o){let l=`archived[${p.target}]`,n=s.resolve(p.target),m=n?s.tipOf(n.cid):null;if(!m||(s.trust.get(m)??null)==="archived"){e.push({code:"ARCHIVE_TARGET_UNKNOWN",detail:`${l}: target does not resolve to an existing, live item`});continue}let f=qe(s,m);if(!f.has(p.basis)){e.push({code:"ARCHIVE_FOREIGN_PROVENANCE",detail:`${l}: its provenance does not include ${p.basis} \u2014 an archive claim must come from a source that evidences the item`});continue}if(!d.has(p.basis)){e.push({code:"ARCHIVE_WITHOUT_COMPLETE_CLAIM",detail:`${l}: ${p.basis} was not read by this extraction \u2014 a completeness claim only counts for a source this run actually read`});continue}if(!je(r,p.basis)){e.push({code:"ARCHIVE_WITHOUT_COMPLETE_CLAIM",detail:`${l}: archiving needs an EXPLICIT complete extraction claim for ${p.basis} (the omitted-claims default does not count) \u2014 add extraction_claims`});continue}if(c.has(m)){e.push({code:"ARCHIVE_TARGET_MATCHED",detail:`${l}: 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 a=[...f].filter(S=>S!==p.basis);if(a.length>0){e.push({code:"ARCHIVE_OTHER_LIVE_EVIDENCE",detail:`${l}: still evidenced by ${a.join(", ")} \u2014 an item another live source evidences is never archived from here`});continue}t.push({op:p,cid:m})}return{valid:t,errors:e}}function Se(r,s,t){return r.superseded.has(t)}function ke(r){let{graph:s,oldTip:t,newCid:e,newLabel:o,by:d}=r,c=[],p=[],l=[],n=[],m=new Set;for(let f of s.edgesFrom(t)){if(f.type===w.DERIVES||r.skipEcids?.has(f.ecid))continue;p.push({kind:"edge",ecid:f.ecid,reason:r.reason,by:d}),m.add(f.ecid);let a=r.dstRedirect?.get(f.dst)??f.dst,S=s.nodeLabel.get(f.dst)??"(unknown)",v=de(f.type,o,S,f.props);if(v.length>0){l.push(`rebless ${f.type} \u2192 ${f.dst}: ${v.map(b=>b.detail).join("; ")}`);continue}let N=be(s,{type:f.type,src:e,dst:a},{pending:n,retracted:m},`rebless ${f.type}`);if(N){l.push(N.detail);continue}let y=q(f.type,e,a,f.props);if(s.superseded.has(y)){l.push(`rebless ${f.type} \u2192 ${a}: the re-derived edge (${y}) was retracted \u2014 retraction is terminal, the successor cannot revive it`);continue}c.push({ecid:y,type:f.type,src:e,dst:a,props:f.props}),n.push({src:e,dst:a,type:f.type})}return{edges:c,supersessions:p,errors:l}}var ae=/^[a-z0-9][a-z0-9-]{1,63}$/;function De(r,s,t,e){if(!s)return{error:{code:"SUPERSEDE_TARGET_MISSING",detail:"supersede verdict needs a target (slug or cid)"}};let o=r.resolve(s);return o?o.superseded||e.has(o.cid)?{error:{code:"ALREADY_SUPERSEDED",detail:`${s} is already superseded (tip: ${o.tip})`}}:o.cid===t?{error:{code:"SELF_SUPERSEDE",detail:"a node cannot supersede itself"}}:{targetCid:o.cid}:{error:{code:"UNKNOWN_SUPERSEDE_TARGET",detail:`${s} names nothing in the graph`}}}function Ke(r,s,t,e,o=[]){if(!oe(s)?.acyclic)return null;if(t===e)return{code:"EDGE_CYCLE",detail:`${s} ${t} \u2192 itself`};let c=n=>[...r.edgesFrom(n).filter(m=>m.type===s).map(m=>m.dst),...o.filter(m=>m.type===s&&m.src===n).map(m=>m.dst)],p=new Set,l=[e];for(;l.length>0;){let n=l.pop();if(n===t)return{code:"EDGE_CYCLE",detail:`${s} ${t} \u2192 ${e} closes a cycle`};p.has(n)||(p.add(n),l.push(...c(n)))}return null}function Rt(r,s,t,e){let d=oe(s)?.cardinality;if(d!=="one-live-per-src"&&d!=="one-live-per-src-and-dst")return null;let c=r.edgesFrom(t).filter(p=>p.type===s&&!r.superseded.has(p.dst));if(c.length>0)return{code:"CARDINALITY_VIOLATION",detail:`${s} from ${t} already has a live edge (${c[0].ecid}) \u2014 supersede it first`};if(d==="one-live-per-src-and-dst"&&e!==void 0){let p=r.edgesInto(e).filter(l=>l.type===s&&!r.superseded.has(l.src));if(p.length>0)return{code:"CARDINALITY_VIOLATION",detail:`${s} onto ${e} already has a live edge (${p[0].ecid}) \u2014 strict 1:1, supersede it first`}}return null}var Ie=new Set(["high","med","low"]),ge=r=>r.cites&&r.cites.length>0?r.cites:[r.cite];function he(r){let s=0;for(let t of r)typeof t=="object"&&t!==null&&"op"in t&&s++;return s===0?"flat":s===r.length?"ops":"mixed"}var We=/^c[1-9][0-9]*$/;function Ae(r,s,t,e){let o=new Map,d=[],c=[];for(let[l,n]of s.entries()){let m=`${r}.updated.criteria[${l}]`;if(n.op==="keep"||n.op==="remove"){if(!We.test(n.ref??"")){e.push({code:"CRITERIA_REF_UNKNOWN",detail:`${m}: ref ${JSON.stringify(n.ref)} is not a c<N> criterion index`});continue}if(o.has(n.ref)){e.push({code:"CRITERIA_REF_DUPLICATE",detail:`${m}: ${n.ref} is already named by another op \u2014 every prior criterion appears in exactly one keep or remove`});continue}o.set(n.ref,n);let f=Number.parseInt(n.ref.slice(1),10);if(f>t.length){e.push({code:"CRITERIA_REF_UNKNOWN",detail:`${m}: ${n.ref} \u2014 the live target has ${t.length} criteria`});continue}if(t[f-1]!==n.text){e.push({code:"CRITERIA_REF_MISMATCH",detail:`${m}: ${n.ref} echo mismatch \u2014 the live target's criterion ${f} reads ${JSON.stringify(t[f-1])}, the op echoed ${JSON.stringify(n.text)} \u2014 re-read the node and re-emit`});continue}n.op==="remove"&&(d.push(n.text),(!n.reason||!n.reason.trim())&&e.push({code:"EMPTY_REASON",detail:`${m}: a remove op carries its reason`}))}else!n.text||!n.text.trim()?e.push({code:"EMPTY_CRITERION",detail:`${m}: set text is empty`}):c.push(n.text)}let p=[];for(let l=1;l<=t.length;l++)o.has(`c${l}`)||p.push(`c${l}`);p.length>0&&e.push({code:"CRITERIA_PARTITION_INCOMPLETE",detail:`${r}: prior criteria ${p.join(", ")} named by no keep/remove op \u2014 every prior criterion must be kept or removed (with a reason)`});for(let l of d)c.includes(l)&&e.push({code:"CRITERIA_OP_CONFLICT",detail:`${r}: ${JSON.stringify(l)} is removed AND re-set in the same update \u2014 drop one of the two ops`})}function bt(r,s,t){let e=[],o=r.sources??[r.source],d=new Map(o.map(n=>[n.source_id,n.source_cid])),c=new Map;if(typeof s=="string")c.set(r.source.source_id,{media:t.mediaOf(r.source.source_cid),numberedText:s});else for(let[n,m]of s)c.set(n,m);for(let n of o)t.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 p=(n,m)=>{let f=m.source_id??r.source.source_id;if(!d.has(f)){e.push({code:"CITE_SOURCE_UNKNOWN",detail:`${n}: cite source ${JSON.stringify(f)} is not in read_basis`});return}let a=c.get(f);if(!a){e.push({code:"MISSING_SOURCE_NODE",detail:`${n}: no citable text available for source ${f}`});return}for(let S of Te(a.media,m,a.numberedText))e.push({code:S.code,detail:`${n}: ${S.detail}`})},l=new Set;for(let n of r.use_cases){if(l.has(n.temp_ref)&&e.push({code:"DUP_TEMP_REF",detail:`duplicate temp_ref ${n.temp_ref}`}),l.add(n.temp_ref),(!n.title||!n.title.trim())&&e.push({code:"EMPTY_TITLE",detail:`${n.temp_ref}: title is empty`}),Ie.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 ge(n))p(n.temp_ref,f);n.matches_existing&&!t.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,a]of(n.criteria??[]).entries())(!a.text||!a.text.trim())&&e.push({code:"EMPTY_CRITERION",detail:`${n.temp_ref}.criteria[${f}]: text is empty`}),!a.cite||!a.cite.anchor?e.push({code:"MISSING_CITE",detail:`${n.temp_ref}.criteria[${f}]: every criterion carries its own cite`}):p(`${n.temp_ref}.criteria[${f}]`,a.cite);let m=n.updated?.criteria??[];if(m.length>0){let f=he(m);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 a=m,S=n.matches_existing?Ye(t,n.matches_existing.cid):null;if(!S)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 v=t.getNode(S.cid)?.content.criteria??[];Ae(n.temp_ref,a,v,e)}for(let[v,N]of a.entries())N.op==="set"&&(!N.cite||!N.cite.anchor?e.push({code:"MISSING_CITE",detail:`${n.temp_ref}.updated.criteria[${v}]: a set op carries the proposing source's cite`}):p(`${n.temp_ref}.updated.criteria[${v}]`,N.cite))}else for(let[a,S]of m.entries())(!S.text||!S.text.trim())&&e.push({code:"EMPTY_CRITERION",detail:`${n.temp_ref}.updated.criteria[${a}]: text is empty`}),!S.cite||!S.cite.anchor?e.push({code:"MISSING_CITE",detail:`${n.temp_ref}.updated.criteria[${a}]: every updated criterion carries its own cite`}):p(`${n.temp_ref}.updated.criteria[${a}]`,S.cite)}}return e.push(...ve(r,t).errors),e}function Be(r,s,t){return`${r}:${s}:${t}`}function Je(r,s,t,e){let o=`${s}:${t}:`,d=0;for(let c of r.appliedEvents){if(!c.startsWith(o))continue;let p=c.slice(o.length);if(!/^\d+$/.test(p))continue;let l=Number.parseInt(p,10);l>d&&(d=l)}return Array.from({length:e},(c,p)=>Be(s,t,d+1+p))}function Ye(r,s){let t=r.resolve(s);if(t===null)return null;let e=t.cid;if(r.superseded.has(e)){let o=r.tipOf(e);return r.superseded.has(o)?null:{cid:o,redirected:!0}}return{cid:e,redirected:!1}}function Ot(r){let{contextDir:s,graph:t,proposal:e,proposalId:o,verdicts:d,by:c,allowStaleBasis:p,extractorVersion:l,autoName:n}=r,m=le(s);if(!p&&e.read_basis!==m)return{record:null,errors:[{code:"STALE_BASIS",detail:`proposal read_basis ${String(e.read_basis)} != latest ${String(m)}`}]};for(let i of e.sources??[e.source])if(!t.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])),a=[],S=[],v=new Map,N=[],y=t.mediaOf(e.source.source_cid),b=new Set,V=[],A=[],K=[],P=[];for(let i of ve(e,t).valid)P.push({id:i.cid,kind:"pending_archive",resolution:"pending",edit:null,reason:i.op.reason,by:c});let J=[],ie=[],g=new Set,_=new Set,I=(i,h,F)=>{let Y=De(t,h.supersedeTarget,F,g);if("error"in Y){a.push({code:Y.error.code,detail:`${i}: ${Y.error.detail}`});return}g.add(Y.targetCid),J.push({kind:"node",old:Y.targetCid,new:F,reason:h.reason??`superseded via review by ${c.id}`,by:c})};for(let i of e.use_cases){let h=d.get(i.temp_ref)??{resolution:"skipped"};b.has(i.temp_ref)&&a.push({code:"DUP_TEMP_REF",detail:`duplicate temp_ref ${i.temp_ref}`}),b.add(i.temp_ref),(!i.title||!i.title.trim())&&a.push({code:"EMPTY_TITLE",detail:`${i.temp_ref}: title is empty`}),Ie.has(i.risk)||a.push({code:"BAD_RISK",detail:`${i.temp_ref}: risk ${JSON.stringify(i.risk)} not in high|med|low`});let F=pe(i.cite?.anchor??""),Y=i.cite?.source_id!==void 0&&f.has(i.cite.source_id)?t.mediaOf(f.get(i.cite.source_id)):y;if(Y.format==="image"){if(F?.kind!=="img-whole"){a.push({code:i.cite?.anchor?"CITE_ANCHOR_INVALID":"MISSING_CITE",detail:`${i.temp_ref}: image cites are anchor-only (img#whole)`});continue}}else if(F?.kind==="img-part"){if(!(Y.images??[]).some(E=>E.ref===F.ref)){a.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){a.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()&&a.push({code:"EMPTY_TITLE",detail:`${i.temp_ref}: edited title is empty`}),h.edit.risk!==void 0&&!Ie.has(h.edit.risk)&&a.push({code:"BAD_RISK",detail:`${i.temp_ref}: edited risk ${JSON.stringify(h.edit.risk)} invalid`}));let me=ue({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)}:{}}),x=se("usecase",me),_e=i.cite.source_id??e.source.source_id,Ce=f.get(_e);if(i.cite.source_id!==void 0&&Ce===void 0){a.push({code:"CITE_SOURCE_UNKNOWN",detail:`${i.temp_ref}: cite source ${JSON.stringify(_e)} is not in read_basis`});continue}let Z={source_id:_e,source_cid:Ce??e.source.source_cid,anchor:i.cite.anchor,...i.cite.quote?{quote:i.cite.quote}:{}};if(i.matches_existing&&!t.hasNode(i.matches_existing.cid)){a.push({code:"UNKNOWN_MATCH",detail:`${i.temp_ref}: matches_existing ${i.matches_existing.cid} is not in the graph`});continue}let R=i.matches_existing?.cid??(t.hasNode(x)?x:null);if(R&&t.superseded.has(R)){let u=t.tipOf(R);R=t.superseded.has(u)?null:u}if(R&&i.matches_existing&&(t.trust.get(R)??null)==="derived"){let u=i.updated?.criteria??[];if(i.changed&&u.length>0&&he(u)==="ops"&&(h.resolution==="approved"||h.resolution==="edited")){a.push({code:"UC_UNREVIEWED",detail:`${i.temp_ref}: merge target ${R.slice(0,19)} is unreviewed (derived) \u2014 bless it first (kane-cli context review) and re-propose the merge`});continue}let E=(r.probeHits??[]).find(C=>C.tempRef===i.temp_ref&&C.candidateCid===R);N.push({tempRef:i.temp_ref,candidate_cid:R,score:E?.score??1,scorer:E?.scorer??"lexical_fallback"}),R=null}if(R){if(i.changed&&(h.resolution==="approved"||h.resolution==="edited")){let u=i.updated;if(!u||Object.keys(u).length===0){a.push({code:"CHANGED_NEEDS_PAYLOAD",detail:`${i.temp_ref}: changed:true needs an updated{...} payload naming the moved fields`});continue}let E=t.getNode(R)?.content??{},C=u.criteria??[],M=C.length>0?he(C):"flat";if(M==="mixed"){a.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(M==="ops"){let L=C,H=E.criteria??[],j=a.length;Ae(i.temp_ref,L,H,a);for(let[ne,ce]of L.entries())ce.op==="set"&&(!ce.cite||!ce.cite.anchor)&&a.push({code:"MISSING_CITE",detail:`${i.temp_ref}.updated.criteria[${ne}]: a set op carries the proposing source's cite`});if(a.length>j)continue;let T=L.filter(ne=>ne.op!=="remove").map(ne=>ne.text),B=ue({title:h.edit?.title??u.title??String(E.title??i.title),...u.description??E.description?{description:u.description??E.description}:{},...h.edit?.summary??u.summary??E.summary?{summary:h.edit?.summary??u.summary??E.summary}:{},...u.actors??E.actors?{actors:u.actors??E.actors}:{},...u.value??E.value?{value:u.value??E.value}:{},risk:h.edit?.risk??u.risk??String(E.risk??i.risk),...T.length>0?{criteria:T}:{}}),Q=se("usecase",B);if(Q!==R){for(let $ of re("usecase",B))a.push({code:$.code,detail:`${i.temp_ref}: ${$.detail}`});V.push({cid:Q,label:te.USECASE,content:B});for(let $ of ge(i)){let X=$.source_id??e.source.source_id,W=f.get(X);if(!W){a.push({code:"CITE_SOURCE_UNKNOWN",detail:`${i.temp_ref}: cite source ${JSON.stringify(X)} is not in read_basis`});continue}let z={source_id:X,source_cid:W,anchor:$.anchor,...$.quote?{quote:$.quote}:{}};A.push({ecid:q("DERIVES",W,Q,z),type:w.DERIVES,src:W,dst:Q,props:z})}let ce=fe(t,R).flatMap($=>t.edgesInto($)).filter($=>$.type===w.DERIVES&&typeof $.props.claim=="string");for(let $ of L){if($.op!=="keep")continue;let X=new Set;for(let W of ce){let z=W.props;if(z.claim!==$.text)continue;let $e=`${z.source_id}|${z.source_cid}|${z.anchor}`;if(X.has($e))continue;X.add($e);let ye={...W.props};A.push({ecid:q("DERIVES",W.src,Q,ye),type:w.DERIVES,src:W.src,dst:Q,props:ye})}}for(let $ of L){if($.op!=="set")continue;let X=$.cite.source_id??e.source.source_id,W=f.get(X);if(!W){a.push({code:"CITE_SOURCE_UNKNOWN",detail:`${i.temp_ref}: set cite source ${JSON.stringify(X)} is not in read_basis`});continue}let z={source_id:X,source_cid:W,anchor:$.cite.anchor,...$.cite.quote?{quote:$.cite.quote}:{},claim:$.text};A.push({ecid:q("DERIVES",W,Q,z),type:w.DERIVES,src:W,dst:Q,props:z})}for(let $ of L)$.op==="remove"&&S.push({about:R,ref:$.ref,text:$.text,reason:$.reason});I(i.temp_ref,{resolution:"supersede",supersedeTarget:R,reason:h.reason??`criteria merge: ${e.source.source_id} (${L.filter($=>$.op==="keep").length} kept, ${L.filter($=>$.op==="set").length} set, ${L.filter($=>$.op==="remove").length} removed)`},Q),P.push({id:Q,kind:"review-item",resolution:h.resolution,edit:h.resolution==="edited"?{...h.edit}:null,reason:null,by:c});continue}}else{let L=C.map(T=>typeof T=="string"?{text:T,cite:void 0}:T),H=ue({title:h.edit?.title??u.title??String(E.title??i.title),...u.description??E.description?{description:u.description??E.description}:{},...h.edit?.summary??u.summary??E.summary?{summary:h.edit?.summary??u.summary??E.summary}:{},...u.actors??E.actors?{actors:u.actors??E.actors}:{},...u.value??E.value?{value:u.value??E.value}:{},risk:h.edit?.risk??u.risk??String(E.risk??i.risk),...u.criteria?L.length>0?{criteria:L.map(T=>T.text)}:{}:E.criteria?{criteria:E.criteria}:{}}),j=se("usecase",H);if(j!==R){for(let T of re("usecase",H))a.push({code:T.code,detail:`${i.temp_ref}: ${T.detail}`});V.push({cid:j,label:te.USECASE,content:H}),A.push({ecid:q("DERIVES",Z.source_cid,j,Z),type:w.DERIVES,src:Z.source_cid,dst:j,props:Z});for(let T of L){if(!T.cite)continue;let B={source_id:e.source.source_id,source_cid:e.source.source_cid,anchor:T.cite.anchor,...T.cite.quote?{quote:T.cite.quote}:{},claim:T.text};A.push({ecid:q("DERIVES",B.source_cid,j,B),type:w.DERIVES,src:B.source_cid,dst:j,props:B})}I(i.temp_ref,{resolution:"supersede",supersedeTarget:R,reason:h.reason??`matches-but-changed: ${e.source.source_id} moved (${Object.keys(u).join(", ")})`},j),P.push({id:j,kind:"review-item",resolution:h.resolution,edit:h.resolution==="edited"?{...h.edit}:null,reason:null,by:c});continue}for(let T of L){if(!T.cite)continue;let B={source_id:e.source.source_id,source_cid:e.source.source_cid,anchor:T.cite.anchor,...T.cite.quote?{quote:T.cite.quote}:{},claim:T.text};A.push({ecid:q("DERIVES",B.source_cid,R,B),type:w.DERIVES,src:B.source_cid,dst:R,props:B})}}}if(i.changed&&h.resolution==="skipped"){let u=i.updated?.criteria??[];u.length>0&&he(u)==="ops"&&P.push({id:R,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:c})}if(h.resolution!=="rejected"){for(let u of ge(i)){let E=u.source_id??e.source.source_id,C=f.get(E);if(!C){a.push({code:"CITE_SOURCE_UNKNOWN",detail:`${i.temp_ref}: cite source ${JSON.stringify(E)} is not in read_basis`});continue}let M={source_id:E,source_cid:C,anchor:u.anchor,...u.quote?{quote:u.quote}:{}};A.push({ecid:q("DERIVES",C,R,M),type:w.DERIVES,src:C,dst:R,props:M})}(h.resolution==="approved"||h.resolution==="edited"||h.resolution==="supersede")&&P.push({id:R,kind:"review-item",resolution:"approved",edit:null,reason:null,by:c}),h.resolution==="supersede"&&I(i.temp_ref,h,R)}continue}for(let u of re("usecase",me))a.push({code:u.code,detail:`${i.temp_ref}: ${u.detail}`});for(let u of de(w.DERIVES,"source","usecase",Z))a.push({code:u.code,detail:`${i.temp_ref}: ${u.detail}`});V.push({cid:x,label:te.USECASE,content:me}),v.set(i.temp_ref,x),A.push({ecid:q("DERIVES",Z.source_cid,x,Z),type:w.DERIVES,src:Z.source_cid,dst:x,props:Z});for(let u of ge(i).slice(1)){let E=u.source_id??e.source.source_id,C=f.get(E);if(!C){a.push({code:"CITE_SOURCE_UNKNOWN",detail:`${i.temp_ref}: cite source ${JSON.stringify(E)} is not in read_basis`});continue}let M={source_id:E,source_cid:C,anchor:u.anchor,...u.quote?{quote:u.quote}:{}};for(let L of de(w.DERIVES,"source","usecase",M))a.push({code:L.code,detail:`${i.temp_ref}: ${L.detail}`});A.push({ecid:q("DERIVES",C,x,M),type:w.DERIVES,src:C,dst:x,props:M})}for(let u of i.criteria??[]){let E=u.cite.source_id??e.source.source_id,C=f.get(E);if(!C){a.push({code:"CITE_SOURCE_UNKNOWN",detail:`${i.temp_ref}: criterion cite source ${JSON.stringify(E)} is not in read_basis`});continue}let M={source_id:E,source_cid:C,anchor:u.cite.anchor,...u.cite.quote?{quote:u.cite.quote}:{},claim:u.text};A.push({ecid:q("DERIVES",M.source_cid,x,M),type:w.DERIVES,src:M.source_cid,dst:x,props:M})}for(let u of i.depends_on_hint??[]){let E=H=>H.toLowerCase().trim().replace(/\s+/g," "),C=null,M=t.resolve(u);if(M&&!M.superseded&&t.nodeLabel.get(M.cid)===te.USECASE&&(C=M.cid),!C){for(let{cid:H,content:j}of t.byLabel(te.USECASE))if(!t.superseded.has(H)&&E(String(j.title??""))===E(u)){C=H;break}}if(!C){let H=V.find(j=>j.label===te.USECASE&&E(String(j.content.title??""))===E(u));H&&(C=H.cid)}!C||C===x||Ke(t,w.DEPENDS_ON,x,C,K)||K.some(H=>H.src===x&&H.dst===C)||(A.push({ecid:q(w.DEPENDS_ON,x,C,{reason:"extract hint"}),type:w.DEPENDS_ON,src:x,dst:C,props:{reason:"extract hint"}}),K.push({src:x,dst:C,type:w.DEPENDS_ON}))}if((h.resolution==="approved"||h.resolution==="edited"||h.resolution==="supersede")&&t.superseded.get(x)===null&&!g.has(x)&&J.push({kind:"node",old:x,new:x,reason:`re-minted after tombstone via review by ${c.id}`,by:c}),n){let u=we("usecase",E=>_.has(E),t.names.keys());u!==null&&!t.nameOf.has(x)&&(_.add(u),ie.push({cid:x,slug:u,by:c}))}h.resolution==="approved"?P.push({id:x,kind:"review-item",resolution:"approved",edit:null,reason:null,by:c}):h.resolution==="edited"?P.push({id:x,kind:"review-item",resolution:"edited",edit:{...h.edit},reason:null,by:c}):h.resolution==="rejected"?P.push({id:x,kind:"review-item",resolution:"rejected",edit:null,reason:h.reason??null,by:c}):h.resolution==="supersede"&&(P.push({id:x,kind:"review-item",resolution:"approved",edit:null,reason:h.reason??null,by:c}),I(i.temp_ref,h,x))}if(a.length)return{record:null,errors:a};let O=new Date().toISOString(),G=(e.sources?.length??0)>1||(e.extraction_claims?.length??0)>0,D;if(G){let i=[];if(e.extraction_claims==null)i.push({source_id:e.source.source_id,source_cid:e.source.source_cid,completeness:"complete",...l?{extractor_version:l}:{},at:O});else{let h=new Map(e.extraction_claims.map(F=>[F.source_id,F.completeness]));for(let F of e.sources??[e.source]){let Y=h.get(F.source_id)??null;Y!==null&&i.push({source_id:F.source_id,source_cid:F.source_cid,completeness:Y,...l?{extractor_version:l}:{},at:O})}}D=i}else D=e.source.source_cid;let k=[];for(let i of r.probeHits??[])k.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 N){let h=v.get(i.tempRef);k.some(F=>F.new_cid===h&&F.candidate_cid===i.candidate_cid)||k.push({...h!==void 0?{new_cid:h}:{},candidate_cid:i.candidate_cid,score:i.score,scorer:i.scorer,probe_basis:null})}return{record:ee(s,{ts:O,proposal_id:o,...o!=null?{extraction_of:D}:{},...o!=null&&l?{extractor_version:l}:{},...S.length>0?{criteria_removed:S}:{},...k.length>0?{dedup_hits:k}:{},nodes:V,edges:A,review:P,supersessions:J,...ie.length>0?{names:ie}:{},...r.judgements&&r.judgements.length>0?{judgements:r.judgements}:{},...r.eventIds&&r.eventIds.length>0?{event_ids:r.eventIds}:r.sid?{event_ids:Je(t,r.sid,"extract",1)}:{},...r.sid?{sid:r.sid}:{},source_head_moves:{}},{expectPrev:m}).record,errors:null}}function wt(r){let{contextDir:s,graph:t,verdicts:e,by:o}=r,d=[],c=[],p=[],l=[],n=[],m=new Set,f=new Map;for(let[S,v]of e){if(v.resolution!=="edited")continue;let N=t.resolve(S);if(!N||N.superseded)continue;let y=t.getNode(N.cid);if(!y)continue;let b={...y.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(re(y.label,b).length>0)continue;let V=se(y.label,b);V===N.cid||Se(t,N.cid,V)||f.set(N.cid,V)}for(let[S,v]of e){if(v.resolution==="skipped")continue;let N=t.resolve(S);if(!N){d.push({code:"UNKNOWN_NODE",detail:`${S} names nothing in the graph`});continue}if(N.superseded){d.push({code:"SUPERSEDED_TARGET",detail:`${S} is superseded \u2014 review the tip (${N.tip})`});continue}let y=N.cid;if(v.resolution==="approved")l.push({id:y,kind:"review-item",resolution:"approved",edit:null,reason:null,by:o});else if(v.resolution==="rejected")r.holdArchives?l.push({id:y,kind:"pending_archive",resolution:"pending",edit:null,reason:v.reason??null,by:o}):l.push({id:y,kind:"review-item",resolution:"rejected",edit:null,reason:v.reason??null,by:o});else if(v.resolution==="edited"){if(m.has(y)){d.push({code:"DUPLICATE_TARGET",detail:`${S}: this node was already superseded by another verdict in this batch \u2014 one verdict per node`});continue}let b=t.getNode(y);if(!b){d.push({code:"UNKNOWN_NODE",detail:`${S}: node file unreadable`});continue}let V={...b.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}:{}},A=re(b.label,V);if(A.length>0){for(let J of A)d.push({code:J.code,detail:`${S}: ${J.detail}`});continue}let K=se(b.label,V);if(K===y){l.push({id:y,kind:"review-item",resolution:"approved",edit:null,reason:null,by:o});continue}if(Se(t,y,K)){d.push({code:"SUPERSEDE_CYCLE",detail:`${S}: edit reproduces an already-superseded version (supersession cycle guard) \u2014 re-edit forward or redesign`});continue}let P=ke({graph:t,oldTip:y,newCid:K,newLabel:b.label,by:o,reason:`re-blessed onto ${K} (edited in review)`,dstRedirect:f});if(P.errors.length>0){for(let J of P.errors)d.push({code:"REBLESS_REFUSED",detail:`${S}: ${J}`});continue}c.push({cid:K,label:b.label,content:V}),p.push(...P.edges),m.add(y),n.push({kind:"node",old:y,new:K,reason:v.reason??"edited in review",by:o}),n.push(...P.supersessions),l.push({id:K,kind:"review-item",resolution:"edited",edit:{...v.edit},reason:null,by:o})}else if(v.resolution==="supersede"){let b=De(t,v.supersedeTarget,y,m);if("error"in b){d.push({code:b.error.code,detail:`${S}: ${b.error.detail}`});continue}m.add(b.targetCid),r.holdArchives?l.push({id:b.targetCid,kind:"pending_archive",resolution:"pending",edit:null,reason:`supersede by ${y}${v.reason?` \u2014 ${v.reason}`:""}`,by:o}):(n.push({kind:"node",old:b.targetCid,new:y,reason:v.reason??`superseded via review by ${o.id}`,by:o}),l.push({id:y,kind:"review-item",resolution:"approved",edit:null,reason:v.reason??null,by:o}))}}return d.length?{record:null,errors:d}:l.length===0&&n.length===0?{record:null,errors:[{code:"NO_VERDICTS",detail:"every item was skipped \u2014 nothing to commit"}]}:{record:ee(s,{ts:new Date().toISOString(),proposal_id:null,nodes:c,edges:p,review:l,supersessions:n,source_head_moves:{}},{expectPrev:t.latestHash}).record,errors:null}}function Tt(r){let{contextDir:s,graph:t,survivor:e,merged:o,reason:d,by:c}=r,p=t.resolve(e),l=t.resolve(o);return p?l?p.superseded||l.superseded?{record:null,errors:[{code:"ALREADY_SUPERSEDED",detail:"a side of the pair is already superseded \u2014 the pair is drained"}]}:p.cid===l.cid?{record:null,errors:[{code:"SELF_SUPERSEDE",detail:"a pair cannot merge a node into itself"}]}:{record:ee(s,{ts:new Date().toISOString(),proposal_id:null,nodes:[],edges:[],review:[],supersessions:[{kind:"node",old:l.cid,new:p.cid,reason:d??`pair merge: duplicate of ${e}`,by:c}],source_head_moves:{}},{expectPrev:t.latestHash}).record,errors:null}:{record:null,errors:[{code:"UNKNOWN_NODE",detail:`${o} names nothing in the graph`}]}:{record:null,errors:[{code:"UNKNOWN_NODE",detail:`${e} names nothing in the graph`}]}}function kt(r){let{contextDir:s,graph:t,assignments:e,by:o}=r,d=[],c=[],p=new Set;for(let{ref:n,slug:m}of e){if(!ae.test(m)){d.push({code:"BAD_SLUG",detail:`${JSON.stringify(m)} \u2014 slugs are kebab-case ${String(ae)}`});continue}let f=t.resolve(n);if(!f){d.push({code:"UNKNOWN_REF",detail:`${n} names nothing in the graph`});continue}if(f.superseded){d.push({code:"SUPERSEDED_TARGET",detail:`${n} is superseded \u2014 name the tip instead (${f.tip})`});continue}let a=t.names.get(m);if(a!==void 0&&!t.superseded.has(a)&&a!==f.cid||p.has(m)){d.push({code:"SLUG_TAKEN",detail:`${m} already names ${a??"another node in this record"}`});continue}p.add(m),c.push({cid:f.cid,slug:m,by:o})}return d.length?{record:null,errors:d}:c.length===0?{record:null,errors:[{code:"NO_ASSIGNMENTS",detail:"nothing to name"}]}:{record:ee(s,{ts:new Date().toISOString(),proposal_id:null,nodes:[],edges:[],review:[],supersessions:[],names:c,source_head_moves:{}},{expectPrev:t.latestHash}).record,errors:null}}function Dt(r){let{contextDir:s,graph:t,sourceId:e,reason:o,by:d}=r,c=t.heads.get(e);return c===void 0?{record:null,errors:[{code:"UNKNOWN_SOURCE",detail:`no source ${e} in the graph`}]}:c===null?{record:null,errors:[{code:"ALREADY_RETIRED",detail:`source ${e} is already retired`}]}:{record:ee(s,{ts:new Date().toISOString(),proposal_id:null,nodes:[],edges:[],review:[],supersessions:[{kind:"node",old:c,new:null,reason:o??`retired source ${e}`,by:d}],source_head_moves:{[e]:null},names:[]},{expectPrev:t.latestHash}).record,errors:null}}function At(r){let s=re("gap",r.content);if(s.length>0)return{ok:!1,refusal:`defer gap failed schema validation: ${s.map(d=>d.detail).join("; ")}`};let t=se("gap",r.content),e={reason:"reconcile change deferred"},o=r.annotates?[{ecid:q(w.ANNOTATES,t,r.annotates,e),type:w.ANNOTATES,src:t,dst:r.annotates,props:e}]:[];for(let d=0;;d++)try{return ee(r.contextDir,{ts:new Date().toISOString(),proposal_id:null,nodes:[{cid:t,label:"gap",content:r.content}],edges:o,review:[],supersessions:[],source_head_moves:{}},{expectPrev:le(r.contextDir)}),{ok:!0,cid:t}}catch(c){if(c instanceof Ee){if(d<3)continue;return{ok:!1,refusal:"concurrent activity kept moving the store \u2014 try the card again"}}throw c}}function Mt(r){let s=r.graph.byLabel("gap").filter(t=>t.content.kind==="reconcile_deferred"&&typeof t.content.uc=="string"&&r.graph.tipOf(t.content.uc)===r.targetTip&&(r.sourceId===void 0||t.content.basis?.source_id===void 0||t.content.basis.source_id===r.sourceId)&&!r.graph.superseded.has(t.cid)&&r.graph.trust.get(t.cid)!=="archived");if(s.length===0)return{resolved:0};for(let t=0;;t++)try{return ee(r.contextDir,{ts:new Date().toISOString(),proposal_id:null,nodes:[],edges:[],review:[],supersessions:s.map(e=>({kind:"node",old:e.cid,new:r.resolvedBy,reason:"reconcile change resolved by a later verdict",by:r.by})),source_head_moves:{}},{expectPrev:le(r.contextDir)}),{resolved:s.length}}catch(e){if(e instanceof Ee){if(t<3)continue;return{resolved:0}}throw e}}export{pe as a,Ue as b,Te as c,ve as d,Se as e,ke as f,ae as g,Ke as h,Rt as i,ge as j,he as k,Ae as l,bt as m,Be as n,Je as o,Ye as p,Ot as q,wt as r,Tt as s,kt as t,Dt as u,At as v,Mt as w,Me as x,Ve as y,ze as z,Oe as A,we as B,dt as C,at as D,fe as E};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as k}from"./chunk-DNNZ353O.js";import{b as w}from"./chunk-W3Z7AZNT.js";import{d as E,e as h}from"./chunk-AKX4VRRR.js";var g=(e,t,r=new Set)=>{let s=e.nameOf.get(t);if(s!==void 0)return s;if(r.has(t))return t;r.add(t);for(let[o,n]of e.superseded){if(n!==t)continue;let d=g(e,o,r);if(d!==o)return d}return t};function b(e,t){let r=e.stale(t);if(r==="fresh")return;if(r==="orphaned")return"orphaned \u2014 no live source evidences this item";let s=[],o=new Map;for(let n of e.derivesInto(t))o.set(String(n.props.source_id),n);for(let[n,d]of o){let i=e.heads.get(n);if(i==null||i===d.props.source_cid)continue;let a=e.convChains.get(n)?.chain;a&&a.includes(String(d.props.source_cid))||s.push(`DERIVES pin ${n}@${String(d.props.source_cid).slice(0,19)} broke \u2014 the source head moved`)}for(let n of e.edgesFrom(t)){if(n.type===h.DERIVES||!e.superseded.has(n.dst))continue;let d=e.tipOf(n.dst);if(e.superseded.has(d)){s.push(`${n.type} pin \u2192 ${g(e,n.dst)} \u2014 target retired`);continue}let i=C(e,n.dst,d);s.push(i.length>0?`${g(e,n.dst)} updated: ${i.map(a=>a.field).join(", ")}`:`${n.type} pin \u2192 ${g(e,n.dst)} \u2014 target superseded`)}return s.length>0?s.join("; "):"stale \u2014 a pinned dependency moved"}function C(e,t,r){let s=e.getNode(t)?.content??{},o=e.getNode(r)?.content??{},n=i=>i===void 0?"":Array.isArray(i)?i.map(String).join(" \xB7 "):typeof i=="object"?JSON.stringify(i):String(i),d=[];for(let i of[...new Set([...Object.keys(s),...Object.keys(o)])].sort())JSON.stringify(s[i])!==JSON.stringify(o[i])&&d.push({field:i,old:n(s[i]),new:n(o[i])});return d}function P(e,t){let r=[];for(let{cid:s}of e.byLabel(E.SCENARIO))e.superseded.has(s)||e.edgesFrom(s).some(o=>o.type===h.BELONGS_TO&&e.tipOf(o.dst)===t)&&r.push(s);return r}function O(e,t){let r=[],s=[],o=[],n=[],d=[],i=[],a=P(e,t),y=new Set(a),l=(c,f)=>{let u=b(e,f);return u===void 0?c:{...c,stale:!0,stale_reason:u}};for(let c of a){let f=e.getNode(c)?.content??{};r.push(l({ref:g(e,c),title:String(f.title??""),case_type:String(f.case_type??""),intent:String(f.intent??"")},c));for(let u of e.edgesInto(c)){if(u.type!==h.AUTOMATES||e.superseded.has(u.src))continue;let p=e.getNode(u.src)?.content??{},S=e.edgesFrom(u.src).filter(x=>x.type===h.VERIFIES&&!e.superseded.has(x.dst)).map(x=>g(e,x.dst));s.push(l({ref:g(e,u.src),title:String(p.title??""),automates:g(e,c),check:p.check,verifies:S,...typeof p.target=="string"?{target:p.target}:{},...typeof p.app=="string"?{app:p.app}:{}},u.src)),d.push(u.src)}for(let u of e.edgesFrom(c))u.type!==h.EXERCISES||e.superseded.has(u.dst)||n.push({scenario:g(e,c),ac:g(e,u.dst)})}for(let{cid:c}of e.byLabel(E.AC)){if(e.superseded.has(c))continue;let f=e.edgesFrom(c).find(x=>x.type===h.SCOPED_TO);if(!f)continue;let u=e.tipOf(f.dst);if(!(u===t||y.has(u)))continue;let S=e.getNode(c)?.content??{};o.push(l({ref:g(e,c),text:String(S.text??""),kind:String(S.kind??""),scope:u===t?"use-case":g(e,u)},c)),i.push(c)}let _=[],m=new Set;for(let c of[t,...a,...d,...i])for(let f of e.retractedEdgesTouching(c))m.has(f.ecid)||(m.add(f.ecid),_.push({type:f.type,src:g(e,f.src),dst:g(e,f.dst),at:f.retraction.at,...f.retraction.reason?{reason:f.retraction.reason}:{}}));return{scenarios:r,tests:s,acs:o,exercises:n,retracted_edges:_}}function D(e,t,r){let s=k(e,t,r);return s===null?null:s.toString("utf8")}function v(e,t){let r=t.split(`
2
+ import{a as k}from"./chunk-DNNZ353O.js";import{b as w}from"./chunk-R4EGL7VM.js";import{d as E,e as h}from"./chunk-AKX4VRRR.js";var g=(e,t,r=new Set)=>{let s=e.nameOf.get(t);if(s!==void 0)return s;if(r.has(t))return t;r.add(t);for(let[o,n]of e.superseded){if(n!==t)continue;let d=g(e,o,r);if(d!==o)return d}return t};function b(e,t){let r=e.stale(t);if(r==="fresh")return;if(r==="orphaned")return"orphaned \u2014 no live source evidences this item";let s=[],o=new Map;for(let n of e.derivesInto(t))o.set(String(n.props.source_id),n);for(let[n,d]of o){let i=e.heads.get(n);if(i==null||i===d.props.source_cid)continue;let a=e.convChains.get(n)?.chain;a&&a.includes(String(d.props.source_cid))||s.push(`DERIVES pin ${n}@${String(d.props.source_cid).slice(0,19)} broke \u2014 the source head moved`)}for(let n of e.edgesFrom(t)){if(n.type===h.DERIVES||!e.superseded.has(n.dst))continue;let d=e.tipOf(n.dst);if(e.superseded.has(d)){s.push(`${n.type} pin \u2192 ${g(e,n.dst)} \u2014 target retired`);continue}let i=C(e,n.dst,d);s.push(i.length>0?`${g(e,n.dst)} updated: ${i.map(a=>a.field).join(", ")}`:`${n.type} pin \u2192 ${g(e,n.dst)} \u2014 target superseded`)}return s.length>0?s.join("; "):"stale \u2014 a pinned dependency moved"}function C(e,t,r){let s=e.getNode(t)?.content??{},o=e.getNode(r)?.content??{},n=i=>i===void 0?"":Array.isArray(i)?i.map(String).join(" \xB7 "):typeof i=="object"?JSON.stringify(i):String(i),d=[];for(let i of[...new Set([...Object.keys(s),...Object.keys(o)])].sort())JSON.stringify(s[i])!==JSON.stringify(o[i])&&d.push({field:i,old:n(s[i]),new:n(o[i])});return d}function P(e,t){let r=[];for(let{cid:s}of e.byLabel(E.SCENARIO))e.superseded.has(s)||e.edgesFrom(s).some(o=>o.type===h.BELONGS_TO&&e.tipOf(o.dst)===t)&&r.push(s);return r}function O(e,t){let r=[],s=[],o=[],n=[],d=[],i=[],a=P(e,t),y=new Set(a),l=(c,f)=>{let u=b(e,f);return u===void 0?c:{...c,stale:!0,stale_reason:u}};for(let c of a){let f=e.getNode(c)?.content??{};r.push(l({ref:g(e,c),title:String(f.title??""),case_type:String(f.case_type??""),intent:String(f.intent??"")},c));for(let u of e.edgesInto(c)){if(u.type!==h.AUTOMATES||e.superseded.has(u.src))continue;let p=e.getNode(u.src)?.content??{},S=e.edgesFrom(u.src).filter(x=>x.type===h.VERIFIES&&!e.superseded.has(x.dst)).map(x=>g(e,x.dst));s.push(l({ref:g(e,u.src),title:String(p.title??""),automates:g(e,c),check:p.check,verifies:S,...typeof p.target=="string"?{target:p.target}:{},...typeof p.app=="string"?{app:p.app}:{}},u.src)),d.push(u.src)}for(let u of e.edgesFrom(c))u.type!==h.EXERCISES||e.superseded.has(u.dst)||n.push({scenario:g(e,c),ac:g(e,u.dst)})}for(let{cid:c}of e.byLabel(E.AC)){if(e.superseded.has(c))continue;let f=e.edgesFrom(c).find(x=>x.type===h.SCOPED_TO);if(!f)continue;let u=e.tipOf(f.dst);if(!(u===t||y.has(u)))continue;let S=e.getNode(c)?.content??{};o.push(l({ref:g(e,c),text:String(S.text??""),kind:String(S.kind??""),scope:u===t?"use-case":g(e,u)},c)),i.push(c)}let _=[],m=new Set;for(let c of[t,...a,...d,...i])for(let f of e.retractedEdgesTouching(c))m.has(f.ecid)||(m.add(f.ecid),_.push({type:f.type,src:g(e,f.src),dst:g(e,f.dst),at:f.retraction.at,...f.retraction.reason?{reason:f.retraction.reason}:{}}));return{scenarios:r,tests:s,acs:o,exercises:n,retracted_edges:_}}function D(e,t,r){let s=k(e,t,r);return s===null?null:s.toString("utf8")}function v(e,t){let r=t.split(`
3
3
  `).map(o=>o.replace(/^\d+\| /,"")),s=[];for(let o of e.split(`
4
4
  `)){let n=o.trim();if(n.length===0)continue;let d=r.find(i=>i.includes(n));d!==void 0&&!s.includes(d.trim())&&s.push(d.trim())}return s.length>0?s.join(`
5
5
  `):{removed:!0}}function G(e,t,r,s){if(s!==void 0&&s.trim().length>0)return{kind:"user-directive",text:s.trim()};let o=[r,...O(t,r).acs.map(a=>t.resolve(a.ref)?.cid??"")].filter(Boolean),n=[],d=new Set;for(let a of o){let y=new Map;for(let l of t.derivesInto(a))y.set(String(l.props.source_id),l);for(let[l,_]of y){let m=t.heads.get(l);if(m==null||m===_.props.source_cid)continue;let c=String(_.props.anchor),f=`${l}\0${c}`;if(d.has(f)||c==="img#whole")continue;d.add(f);let u=D(e,t,String(_.props.source_cid)),p=u===null?null:w(u,c);if(p===null)continue;let S=D(e,t,m);n.push({source_id:l,anchor:c,old_anchor_text:p,new_anchor_text:S===null?{removed:!0}:v(p,S)})}}let i;for(let[a,y]of t.superseded){if(y!==r||t.nodeLabel.get(a)!==E.USECASE)continue;let l=C(t,a,r);l.length>0&&(i=l);break}return{kind:"source-change",changes:n,...i?{uc_updated:i}:{}}}function $(e,t,r,s){let o=O(t,r);if(o.scenarios.length===0&&o.tests.length===0&&o.acs.length===0)return;let n=G(e,t,r,s);if(!(n.kind==="source-change"&&n.changes.length===0&&!n.uc_updated))return{prior_design:o,change_delta:n}}export{O as a,$ as b};
@@ -1,7 +1,7 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{i as S}from"./chunk-KRKGZ2ZW.js";import{a as C,b as k,c as R,d as D}from"./chunk-DF3DUGJS.js";import{j as T,k as $,l as b}from"./chunk-54JZ6VEW.js";import{g as E}from"./chunk-R7QAS6LZ.js";import{c as y}from"./chunk-5DT7PIGB.js";import{a as O}from"./chunk-CH273NAE.js";import{C as _}from"./chunk-W3Z7AZNT.js";import{existsSync as H}from"fs";import{basename as q}from"path";import{appendFileSync as L,mkdirSync as U}from"fs";import{homedir as F}from"os";import{dirname as G,join as j}from"path";function P(c,s){let n=/^(DOCX_[A-Z_]+):/.exec(s)?.[1];if(n)try{let u=process.env.KANE_CONTEXT_REFUSAL_LOG??j(F(),".testmuai","kaneai","context-refusals.log");U(G(u),{recursive:!0}),L(u,`${new Date().toISOString()} ${n} ${c}
2
+ import{g as E}from"./chunk-R7QAS6LZ.js";import{i as S}from"./chunk-XS2LZFCH.js";import{a as C,b as k,c as R,d as D}from"./chunk-YQ4MRF57.js";import{j as T,k as $,l as b}from"./chunk-3D7VYEDP.js";import{c as y}from"./chunk-5DT7PIGB.js";import{a as O}from"./chunk-CH273NAE.js";import{C as _}from"./chunk-R4EGL7VM.js";import{existsSync as H}from"fs";import{basename as q}from"path";import{appendFileSync as L,mkdirSync as U}from"fs";import{homedir as F}from"os";import{dirname as G,join as j}from"path";function P(c,s){let n=/^(DOCX_[A-Z_]+):/.exec(s)?.[1];if(n)try{let u=process.env.KANE_CONTEXT_REFUSAL_LOG??j(F(),".testmuai","kaneai","context-refusals.log");U(G(u),{recursive:!0}),L(u,`${new Date().toISOString()} ${n} ${c}
3
3
  `)}catch{}}async function w(c,s,n,u=process.cwd(),p){let l=O(u),g=[];if(s.as!==void 0&&c.length>1)return(n.err??n.out)(`error: --as names ONE source identity \u2014 pass a single file (got ${c.length})`,"AS_SINGLE_SOURCE"),{code:2,results:g};for(let o of c){if(R(o)){let a=D(o);if(a===null)return(n.err??n.out)(`error: ${o}: unsupported remote URL \u2014 supported: ${k.map(d=>d.hint).join("; ")}`,"UNSUPPORTED_URL"),{code:1,results:g};let r=await a.ingest(o,s.as,n,l,p);if(r.code!==0)return{code:r.code,results:g};r.result&&g.push({status:r.result.status==="versioned"?"versioned":r.result.status==="unchanged"?"unchanged":"created",source_id:r.result.source_id,source_cid:r.result.source_cid});continue}let f=s.as,v;if(f===void 0&&H(l)){let a=T(o),r=$(a);if(r){let d=_(l);d.heads.get(r)!=null&&d.heads.get(a)==null&&(v=r,n.isTTY&&await n.confirm(`${a} looks like a new version of existing source '${r}' \u2014 ingest as '${r}' (replaces the current version; items built on it go stale)?`)&&(f=r))}}let e;try{e=await b({contextDir:l,filePath:o,asId:f,confirmSameSource:n.isTTY?a=>n.confirm(`identical bytes already ingested as ${a} \u2014 treat as the same source?`):void 0,converters:{pdf:E,docx:S}})}catch(a){let r=a instanceof Error?a.message:String(a);return P(o,r),(n.err??n.out)(`error: ${o}: ${r}`,"INGEST_FAILED"),{code:1,results:g}}n.out(C(n.isTTY,e,q(o)));for(let a of e.warnings??[])n.out(`warning: ${a}`);if(e.composite&&(e.composite.delivered>0||e.composite.omitted>0)){let a=e.composite.pages!==void 0?` ${e.composite.pages} pages,`:"";n.out(`${e.source_id}: ${e.composite.kind},${a} ${e.composite.delivered} images delivered (${e.composite.omitted} omitted)`)}let m;if(!n.isTTY&&e.status==="created"){let a=_(l);for(let[r,d]of a.heads.entries())if(!(r===e.source_id||d==null)&&a.getNode(d)?.content.blob===e.blob){m=r,n.out(`hint: identical bytes already ingested as ${r} \u2014 merged later via review`);break}}g.push({status:e.status,source_id:e.source_id,source_cid:e.cid,...e.warnings?.length?{warnings:e.warnings}:{},...e.composite?{media:{kind:e.composite.kind,...e.composite.pages!==void 0?{pages:e.composite.pages}:{},delivered:e.composite.delivered,omitted:e.composite.omitted}}:{},...m?{duplicate_of:m}:{},...v&&f===void 0?{lineage_candidate:v}:{}})}return{code:0,results:g}}async function se(c,s,n,u=process.cwd(),p){return(await w(c,s,n,u,p)).code}async function ie(c,s){if(s.mode!=null&&!["interactive","agent","ci","override"].includes(s.mode)){let{makeHeadlessIO:t,agentRefusal:i}=await import("./headless-io-66RG5NN5.js");return i(t("ndjson","extract"),`ingest: --mode must be interactive | agent | ci | override, got '${s.mode}'`,"MODE_USAGE")}let n=y();if(s.mode==="interactive"&&!n)return process.stderr.write(`ingest: --mode interactive needs a TTY on stdin and stdout (use --mode agent|ci|override headless)
4
4
  `),2;let u=s.mode??(n?"interactive":void 0),p=u==="interactive"||u==="agent"||u==="override";if(!p&&(s.plan||s.force||s.trust!==void 0))return process.stderr.write(`ingest: --plan/--force/--trust steer the extraction \u2014 not available when only landing (use --mode agent to extract headless)
5
5
  `),2;let{createInterface:l}=await import("readline/promises"),g=u==="agent",o=g?(await import("./headless-io-66RG5NN5.js")).makeHeadlessIO("ndjson","extract"):null,f=[],v=()=>{for(let t of f.splice(0))o.event({type:"error",message:t.message,...t.code?{code:t.code}:{}})},e=t=>{for(let i of t)o.event({type:"ingested",source_id:i.source_id,status:i.status,cid:i.source_cid,...i.warnings?.length?{warnings:i.warnings}:{},...i.media?{media:i.media}:{},...i.duplicate_of?{duplicate_of:i.duplicate_of}:{},...i.lineage_candidate?{lineage_candidate:i.lineage_candidate}:{}})},m=o?{out:()=>{},err:(t,i)=>f.push({message:t.replace(/^error: /,""),...i?{code:i}:{}}),isTTY:!1,confirm:async()=>!1}:{out:t=>process.stdout.write(t+`
6
6
  `),err:t=>process.stderr.write(t+`
7
- `),isTTY:n,confirm:async t=>{let i=l({input:process.stdin,output:process.stdout});try{let h=await i.question(`${t} [Y/n] `);return!/^n(o)?$/i.test(h.trim())}finally{i.close()}}};if(!p){let{withTelemetry:t}=await import("./with-telemetry-4ATZC6IR.js");return t("ingest",async()=>{let{code:i,results:h}=await w(c,{as:s.as},m,void 0,void 0);if(i!==0)return i;let I=h.filter(Y=>Y.status!=="unchanged").length;return I>0&&(m.err??m.out)(`landed ${I} source(s) \u2014 run kane-cli context extract to extract them`),0},{write:!0})}let a;try{a=o?await(await import("./run-channel-RGH4WIQX.js")).runWithChannel({event:o.event},()=>w(c,{as:s.as},m,void 0,void 0)):await w(c,{as:s.as},m,void 0,void 0)}catch(t){if(o)return v(),o.event({type:"error",message:t instanceof Error?t.message:String(t),code:"INGEST_FAILED"}),o.done(1,"error");throw t}let{code:r,results:d}=a;if(r!==0)return o?(e(d),v(),o.done(r,r===2?"refused":"error")):r;if(d.length===0)return o?o.done(0):0;let{extractCommand:A}=await import("./extract-cmd-2OFQBBJ4.js"),N=[...new Set(d.map(t=>t.source_id))],x=await A({...s.mode!==void 0?{mode:s.mode}:{},...s.plan?{plan:!0}:{},...s.force?{force:!0}:{},...s.trust!==void 0?{trust:s.trust}:{},sources:N,landed:d});if(x===2&&!g){let t=d.filter(i=>i.status!=="unchanged").length;t>0&&(m.err??m.out)(`note: the ${t} landed source(s) are safe \u2014 extract later with kane-cli context extract`)}return x}export{w as a,se as b,ie as c};
7
+ `),isTTY:n,confirm:async t=>{let i=l({input:process.stdin,output:process.stdout});try{let h=await i.question(`${t} [Y/n] `);return!/^n(o)?$/i.test(h.trim())}finally{i.close()}}};if(!p){let{withTelemetry:t}=await import("./with-telemetry-L3SO6J3L.js");return t("ingest",async()=>{let{code:i,results:h}=await w(c,{as:s.as},m,void 0,void 0);if(i!==0)return i;let I=h.filter(Y=>Y.status!=="unchanged").length;return I>0&&(m.err??m.out)(`landed ${I} source(s) \u2014 run kane-cli context extract to extract them`),0},{write:!0})}let a;try{a=o?await(await import("./run-channel-RGH4WIQX.js")).runWithChannel({event:o.event},()=>w(c,{as:s.as},m,void 0,void 0)):await w(c,{as:s.as},m,void 0,void 0)}catch(t){if(o)return v(),o.event({type:"error",message:t instanceof Error?t.message:String(t),code:"INGEST_FAILED"}),o.done(1,"error");throw t}let{code:r,results:d}=a;if(r!==0)return o?(e(d),v(),o.done(r,r===2?"refused":"error")):r;if(d.length===0)return o?o.done(0):0;let{extractCommand:A}=await import("./extract-cmd-RHVLPNQB.js"),N=[...new Set(d.map(t=>t.source_id))],x=await A({...s.mode!==void 0?{mode:s.mode}:{},...s.plan?{plan:!0}:{},...s.force?{force:!0}:{},...s.trust!==void 0?{trust:s.trust}:{},sources:N,landed:d});if(x===2&&!g){let t=d.filter(i=>i.status!=="unchanged").length;t>0&&(m.err??m.out)(`note: the ${t} landed source(s) are safe \u2014 extract later with kane-cli context extract`)}return x}export{w as a,se as b,ie as c};
@@ -0,0 +1,15 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a as w,c as M}from"./chunk-KRL2BDI5.js";import{dirname as K,basename as N,join as d}from"path";function W(t){let e=N(t);return e.endsWith("_test.md")?e.slice(0,-8):e.endsWith("_module.md")?e.slice(0,-10):e.endsWith(".md")?e.slice(0,-3):e}function f(t){return d(K(t),`output-${W(t)}`)}function nt(t){return d(f(t),"Result.md")}function _(t){return d(f(t),".internal")}function x(t){return d(_(t),"meta.json")}function it(t){return d(_(t),"execution.json")}function rt(t,e,n){return d(f(t),`${e}-${n}-code`)}function ot(t){return d(f(t),"generated-code")}function st(t){return f(t)+".staging"}function G(t){return d(_(t),"steps")}function dt(t,e,n){return d(G(t),`${e}-${n}`)}import{writeFileSync as J,mkdirSync as L,readFileSync as H}from"fs";import{dirname as j}from"path";function k(t){try{return JSON.parse(H(x(t),"utf8"))}catch{return null}}function ut(t){let e=x(t.sourcePath);try{L(j(e),{recursive:!0})}catch(r){return process.stderr.write(`
3
+ \u26A0 Failed to create output directory.
4
+ ${r.message}
5
+ Path: ${j(e)}
6
+
7
+ `),e}let n={commit_id:t.commitId};t.testId!==void 0&&(n.test_id=t.testId),t.testcaseId!==void 0&&(n.testcase_id=t.testcaseId),t.projectId!==void 0&&(n.project_id=t.projectId),t.folderId!==void 0&&(n.folder_id=t.folderId),t.orgId!==void 0&&(n.org_id=t.orgId),t.sessionName!==void 0&&(n.session_name=t.sessionName),t.plan!==void 0&&(n.plan=t.plan);try{J(e,JSON.stringify(n,null,2)+`
8
+ `,"utf8")}catch(r){process.stderr.write(`
9
+ \u26A0 Failed to write meta.json.
10
+ ${r.message}
11
+ Path: ${e}
12
+
13
+ `)}return e}import{readFileSync as Y,existsSync as z}from"fs";import{basename as C,dirname as q,isAbsolute as Q,resolve as T}from"path";import{createHash as O}from"crypto";function h(t){if(t==null)return null;if(Array.isArray(t))return t.map(h);if(typeof t=="object"){let e={};for(let n of Object.keys(t).sort()){let r=t[n];r!==void 0&&(e[n]=h(r))}return e}return t}function U(t){if(t.body.kind!=="objective")throw new Error("stepMd5: only objective steps have an md5; @import rows do not");let e={...t.config??{},optional:t.optional??!1},n=JSON.stringify(h(e));return O("md5").update(t.body.text).update(`
14
+ `).update(n).digest("hex")}function I(t){let e={};for(let[r,o]of Object.entries(t.bindings??{}))e[r]={value:o.value,...o.secret===!0?{secret:!0}:{},...o.syntax?{syntax:o.syntax}:{}};let n=JSON.stringify(h({bindings:e,optional:t.optional}));return O("md5").update(t.path).update(`
15
+ `).update(n).digest("hex")}function mt(t){return U({index:t.trace[t.trace.length-1].stepIndex,heading:t.trace[t.trace.length-1].heading,verifies:[],body:{kind:"objective",text:t.objective},config:t.parsedConfig,headingLine:1,optional:t.optional})}var E=["target","chrome_profile","cdp_endpoint","ws_endpoint","headless"],X=["app","no_reset","os_version","device_name"],Z=["mode","on_lock_conflict","tags","target","chrome_profile","cdp_endpoint","ws_endpoint","headless","app","no_reset","os_version","device_name"],u=class extends Error{constructor(e){super(e),this.name="TestMdResolveError"}};function v(t){let e=C(t);return e.endsWith("_test.md")?"test":e.endsWith("_module.md")?"module":"helper"}function Rt(t){let e=T(t),n=$(e),r=B(n.global),o=[],a=[],s=[{file:e,kind:v(e)}],c=[];return F(n,a,o,[],e,{},s,c,{}),o.forEach((l,b)=>l.flatIndex=b+1),{rootPath:e,rootTitle:n.title,rootGlobal:n.global,rootSteps:n.steps,chrome:r,steps:o,unitFiles:s,warnings:c}}function St(t){let e=[];for(let n of t.unitFiles){if(n.kind!=="test")continue;let r=k(n.file);r&&e.push({file:n.file,...r.project_id?{project_id:String(r.project_id)}:{},...r.org_id?{org_id:String(r.org_id)}:{}})}return e}function $(t){if(!z(t))throw new u(`@import path not found: ${t}`);let e=Y(t,"utf8");return w(t,e)}function F(t,e,n,r,o,a,s,c,p){if(e.includes(t.path)){let i=[...e,t.path].map(g=>C(g)).join(" \u2192 ");throw new u(`cyclic reference: ${i}`)}e.push(t.path);let l=r.length===0,b=t.global.variables??{};for(let i of Object.keys(a))if(Object.hasOwn(b,i))throw new u(`callsite binding '${i}' collides with a declared variable in ${t.path} (frontmatter variables are pinned; parameters are its undeclared names)`);let R=t.global;if(!l){let i={...t.global};for(let g of Z)i[g]!==void 0&&(c.push(`${t.path}: '${g}' is root-governed on imported units \u2014 ignored`),delete i[g]);i.url!==void 0&&(p.pending=String(i.url),delete i.url),R=i}for(let i of t.steps){let g=i.body.kind!=="objective";if(i.optional&&g&&!l)throw new u(`intermediate-ref 'optional' is not supported in v1: ${t.path}:${i.headingLine}`);if(i.body.kind==="objective"){let y={file:t.path,stepIndex:i.index,heading:i.heading,optional:i.optional??!1},D=tt(R,i.config,a),S={flatIndex:0,objective:i.body.text,sourceFile:t.path,trace:[...r,y],config:D,parsedConfig:i.config,optional:i.optional??!1,verifies:i.verifies,owningFile:t.path,unitKind:v(t.path),...i.replayOnly?{replayOnly:i.replayOnly}:{}};p.pending&&(S.unitEntryUrl=p.pending,p.pending=void 0),n.push(S);continue}let P={file:t.path,stepIndex:i.index,heading:i.heading,optional:i.optional??!1,rowMd5:I({path:i.body.path,bindings:i.body.bindings,optional:i.optional??!1})},V=q(t.path),m=Q(i.body.path)?i.body.path:T(V,i.body.path),A=$(m);s.some(y=>y.file===m)||s.push({file:m,kind:v(m)}),F(A,e,n,[...r,P],o,i.body.bindings??{},s,c,p)}l||(p.pending=void 0),e.pop()}function B(t){let e={};for(let n of E){if(n==="target"){let r=M(t);r!==void 0&&(e.target=r);continue}t[n]!==void 0&&(e[n]=t[n])}return e}function tt(t,e,n){let r={};for(let[s,c]of Object.entries(t))E.includes(s)||X.includes(s)||(r[s]=c);let o={...r,...e??{}},a={...n,...t.variables??{},...e?.variables??{}};return Object.keys(a).length>0?o.variables=a:delete o.variables,o}export{W as a,f as b,nt as c,_ as d,x as e,it as f,rt as g,ot as h,st as i,G as j,dt as k,I as l,mt as m,k as n,ut as o,u as p,v as q,Rt as r,St as s};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a as S}from"./chunk-6DOS5CJ5.js";import{x as o}from"./chunk-DEUDRSU7.js";import{a as R}from"./chunk-HCBYKLMW.js";import{a as y,b as c,j as x}from"./chunk-C44QQJR4.js";import{a as w}from"./chunk-6YGTRKDT.js";import{e as b}from"./chunk-UR6MHSHU.js";var k=b(w(),1);var i=b(R(),1);function A(e){let t=e.decisions.filter(l=>l.kind==="replay").length,s=e.decisions.filter(l=>l.kind==="author").length,d=e.outcomes.filter(l=>l.status==="passed").length,f=e.outcomes.filter(l=>l.status==="failed").length,h=e.outcomes.filter(l=>l.status==="skipped").length,a=o.green,u;e.cancelled||e.overallStatus==="interrupted"?(a=o.orange,u="CANCELLED"):e.overallStatus==="failed"?(a=o.red,u="FAILED"):u="PASSED";let r=`${u} \xB7 ${e.durationS}s \xB7 ${e.outcomes.length} steps (${d} passed, ${f} failed, ${h} skipped)`,T=`${t} replay \xB7 ${s} author`,C=e.retryTriggered,_="yes \u2014 healed after a replay miss",n,p=o.dim;if(e.cancelled)n="\u2013 not committed (cancellation)";else if(e.overallStatus==="failed")n="\u2013 not committed (run failed)",p=o.red;else if(!e.shouldCommit)e.isFirstRun?n="\u2013 not committed (first run skipped commit)":e.lockHeld?n="\u2013 not committed":n="\u2013 not committed (readonly fallback / no lock)";else if(e.committed===!1&&!e.uploadResult?.testcaseId)n="\u2013 not committed (commit did not land)",p=o.red;else{let l=e.uploadResult?.testcaseId;n=l?`\u2713 pushed (testcase=${l})`:"\u2713 pushed",p=o.green}let v=e.shouldReplaceLocalOutput?"output dir replaced":e.anyAuthorStepRan?"untouched (cancellation or no replace)":"untouched (replay-only)",m,g=o.dim;return e.shouldUploadArtifacts?e.uploadResult?.success?(m="\u2713 TMS",g=o.green):e.uploadResult?(m=`\u2717 failed${e.uploadResult.error?`: ${e.uploadResult.error}`:""}`,g=o.red):m="\u2013 not run":m="\u2013 skipped (--local or no auth)",{resultLine:{color:a,text:r},breakdown:T,showRetries:C,retriesText:_,commitText:n,commitColor:p,artifactsText:v,uploadText:m,uploadColor:g}}function I(e){let t=e.decisions.filter(r=>r.kind==="replay").length,s=e.decisions.filter(r=>r.kind==="author").length,d=e.outcomes.filter(r=>r.status==="passed").length,f=e.outcomes.filter(r=>r.status==="failed").length,h=e.outcomes.filter(r=>r.status==="skipped").length,a,u=!1;return e.cancelled?a="cancellation":e.overallStatus==="failed"?a="run_failed":e.shouldCommit&&(e.committed===!0||e.uploadResult?.testcaseId)?(a="ok",u=!0):!e.shouldCommit&&!e.lockHeld&&!e.isFirstRun?a="readonly_fallback":a="not_committed",{type:"test_md_summary",overall_status:e.overallStatus,duration_s:e.durationS,steps:{total:e.outcomes.length,passed:d,failed:f,skipped:h,replay_decisions:t,author_decisions:s},adaptive_heal:{triggered:e.retryTriggered},commit:{committed:u,reason:a,...e.uploadResult?.testcaseId?{testcase_id:e.uploadResult.testcaseId}:{}},artifacts:{replaced:e.shouldReplaceLocalOutput},upload:{performed:e.shouldUploadArtifacts,...e.uploadResult?{succeeded:!!e.uploadResult.success}:{}},...e.shareUrl?{share_url:e.shareUrl}:{},cancelled:e.cancelled,...e.imports&&e.imports.length>0?{imports:e.imports}:{}}}function D({data:e}){let t=A(e),s=[{label:"result",value:(0,i.jsx)(c,{color:t.resultLine.color,bold:!0,children:t.resultLine.text})},{label:"breakdown",value:(0,i.jsx)(c,{color:o.dim,children:t.breakdown})}];return t.showRetries&&s.push({label:"adaptive heal",value:(0,i.jsx)(c,{color:o.orange,children:t.retriesText})}),s.push({label:"commit",value:(0,i.jsx)(c,{color:t.commitColor,children:t.commitText})}),s.push({label:"artifacts",value:(0,i.jsx)(c,{color:o.dim,children:t.artifactsText})}),s.push({label:"upload",value:(0,i.jsx)(c,{color:t.uploadColor,children:t.uploadText})}),(0,i.jsx)(S,{title:"Run summary",titleColor:"#ff9500",rows:s})}function O({data:e}){let{exit:t}=x();return(0,k.useEffect)(()=>{let s=setTimeout(()=>t(),50);return()=>clearTimeout(s)},[t]),(0,i.jsx)(y,{flexDirection:"column",children:(0,i.jsx)(D,{data:e})})}export{A as a,I as b,D as c,O as d};
@@ -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-HNNVVK2O.js";import{c as g}from"./chunk-RFHMDQXZ.js";import{a as E}from"./chunk-LUTRUSIV.js";import{x as n}from"./chunk-WEJA3EVI.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-4FXSDPQW.js";import{c as g}from"./chunk-RFHMDQXZ.js";import{a as E}from"./chunk-A76UL3EN.js";import{x as n}from"./chunk-DEUDRSU7.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};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{i as s,j as e}from"./chunk-AKX4VRRR.js";import{a as t,b as i}from"./chunk-IAHKTEET.js";function a(r,n){return"sha256:"+i(Buffer.from("assurance."+r+"\0"+t(s(r,n)),"utf8"))}function f(r,n,o,u){return"sha256:"+i(Buffer.from("assurance.edge\0"+t({type:r,src:n,dst:o,props:e(r,u)}),"utf8"))}function d(r,n){return{source_id:r,blob:n}}function p(r){return{...r,derived:!0}}export{a,f as b,d as c,p as d};
2
+ import{a as t,b as i}from"./chunk-IAHKTEET.js";import{i as s,j as e}from"./chunk-AKX4VRRR.js";function a(r,n){return"sha256:"+i(Buffer.from("assurance."+r+"\0"+t(s(r,n)),"utf8"))}function f(r,n,o,u){return"sha256:"+i(Buffer.from("assurance.edge\0"+t({type:r,src:n,dst:o,props:e(r,u)}),"utf8"))}function d(r,n){return{source_id:r,blob:n}}function p(r){return{...r,derived:!0}}export{a,f as b,d as c,p as d};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{c as k}from"./chunk-RFHMDQXZ.js";import{a as b}from"./chunk-B4CYIZP5.js";import{a as C}from"./chunk-BUM367KV.js";import{p as m,q as u,r as f,s as x,t as y}from"./chunk-WEJA3EVI.js";import{createServer as S}from"http";import{randomBytes as A}from"crypto";import{URL as L}from"url";var P=class{profile;environment;creds;oauth;constructor(r="default",o="prod",e){this.profile=r,this.environment=o,this.creds=e??new C,this.oauth=new b(o)}async login(){let{server:r,port:o}=await this.startCallbackServer(),e=y(o);try{let t=this.creds.loadClient(this.profile,this.environment),i=t?.redirect_uris;(!t||!i?.includes(e))&&(t=await this.oauth.registerClient(e),this.creds.saveClient(this.profile,this.environment,t));let c=t.client_id,[h,d]=b.generatePkce(),a=A(32).toString("hex"),n=this.oauth.buildAuthorizationUrl(c,d,a,e),l=await this.waitForCallback(r,o,n,a);if(!l)throw new Error("Login cancelled or timed out");let p=await this.oauth.exchangeCode(l,c,h,e),g={access_token:p.access_token,refresh_token:p.refresh_token,expires_at:Math.floor(Date.now()/1e3)+p.expires_in,scope:p.scope??"*"};return this.creds.saveCredentials(this.profile,this.environment,g),this.creds.setActiveProfile(this.profile),g}catch(t){throw r.close(),t}}startCallbackServer(){return new Promise((r,o)=>{let e=u,t=()=>{let i=S();i.on("error",c=>{c.code==="EADDRINUSE"&&e<f?(e++,t()):o(new Error(`Failed to start callback server: ${c.message}. Ports ${u}-${f} are all in use.`))}),i.listen(e,m,()=>{r({server:i,port:e})})};t()})}waitForCallback(r,o,e,t){return new Promise(i=>{let c=!1,h=setTimeout(()=>d(null),12e4),d=a=>{c||(c=!0,clearTimeout(h),r.close(),i(a))};r.on("request",(a,n)=>{let l=new L(a.url??"/",`http://${m}:${o}`);if(l.pathname!==x){n.writeHead(404),n.end();return}let p=l.searchParams.get("state"),g=l.searchParams.get("code");if(l.searchParams.get("error")){n.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"error",title:"Login failed",message:"We couldn't complete the sign-in. You can close this tab and try again from your terminal."})),d(null);return}if(p!==t){n.writeHead(400,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"error",title:"Invalid state",message:"The sign-in response didn't match this session. Please return to your terminal and try again."})),d(null);return}n.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"success",title:"You're signed in",message:"Head back to your terminal \u2014 KaneAI is ready when you are.",autoClose:!0})),d(g)}),k(e).catch(a=>{let n=a instanceof Error?a.message:String(a);process.stderr.write(`[auth] Could not open browser: ${n}
2
+ import{c as k}from"./chunk-RFHMDQXZ.js";import{a as b}from"./chunk-XB7EMX6J.js";import{a as C}from"./chunk-NVRXDLJN.js";import{p as m,q as u,r as f,s as x,t as y}from"./chunk-DEUDRSU7.js";import{createServer as S}from"http";import{randomBytes as A}from"crypto";import{URL as L}from"url";var P=class{profile;environment;creds;oauth;constructor(r="default",o="prod",e){this.profile=r,this.environment=o,this.creds=e??new C,this.oauth=new b(o)}async login(){let{server:r,port:o}=await this.startCallbackServer(),e=y(o);try{let t=this.creds.loadClient(this.profile,this.environment),i=t?.redirect_uris;(!t||!i?.includes(e))&&(t=await this.oauth.registerClient(e),this.creds.saveClient(this.profile,this.environment,t));let c=t.client_id,[h,d]=b.generatePkce(),a=A(32).toString("hex"),n=this.oauth.buildAuthorizationUrl(c,d,a,e),l=await this.waitForCallback(r,o,n,a);if(!l)throw new Error("Login cancelled or timed out");let p=await this.oauth.exchangeCode(l,c,h,e),g={access_token:p.access_token,refresh_token:p.refresh_token,expires_at:Math.floor(Date.now()/1e3)+p.expires_in,scope:p.scope??"*"};return this.creds.saveCredentials(this.profile,this.environment,g),this.creds.setActiveProfile(this.profile),g}catch(t){throw r.close(),t}}startCallbackServer(){return new Promise((r,o)=>{let e=u,t=()=>{let i=S();i.on("error",c=>{c.code==="EADDRINUSE"&&e<f?(e++,t()):o(new Error(`Failed to start callback server: ${c.message}. Ports ${u}-${f} are all in use.`))}),i.listen(e,m,()=>{r({server:i,port:e})})};t()})}waitForCallback(r,o,e,t){return new Promise(i=>{let c=!1,h=setTimeout(()=>d(null),12e4),d=a=>{c||(c=!0,clearTimeout(h),r.close(),i(a))};r.on("request",(a,n)=>{let l=new L(a.url??"/",`http://${m}:${o}`);if(l.pathname!==x){n.writeHead(404),n.end();return}let p=l.searchParams.get("state"),g=l.searchParams.get("code");if(l.searchParams.get("error")){n.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"error",title:"Login failed",message:"We couldn't complete the sign-in. You can close this tab and try again from your terminal."})),d(null);return}if(p!==t){n.writeHead(400,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"error",title:"Invalid state",message:"The sign-in response didn't match this session. Please return to your terminal and try again."})),d(null);return}n.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"success",title:"You're signed in",message:"Head back to your terminal \u2014 KaneAI is ready when you are.",autoClose:!0})),d(g)}),k(e).catch(a=>{let n=a instanceof Error?a.message:String(a);process.stderr.write(`[auth] Could not open browser: ${n}
3
3
  Please open this URL manually: ${e}
4
4
  `)})})}};function v(s){let r=s.state==="success",o=r?"#22c55e":"#ef4444",e=r?"rgba(34, 197, 94, 0.12)":"rgba(239, 68, 68, 0.12)",t=r?'<svg viewBox="0 0 24 24" width="36" height="36" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7"/></svg>':'<svg viewBox="0 0 24 24" width="36" height="36" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 6l12 12M18 6L6 18"/></svg>',i=s.autoClose?"<script>setTimeout(function(){try{window.close();}catch(e){}}, 1500);</script>":"";return`<!doctype html>
5
5
  <html lang="en">
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as $}from"./chunk-YCCUBQY4.js";import{a as U}from"./chunk-EKOL4WCC.js";import{a as k}from"./chunk-BPMSNGXQ.js";import{a as _}from"./chunk-KUAFVRSR.js";import{a as T}from"./chunk-FOP6CJAM.js";import{x as i}from"./chunk-WEJA3EVI.js";import{a as O}from"./chunk-HCBYKLMW.js";import{a as u,b as s}from"./chunk-C44QQJR4.js";import{a as K}from"./chunk-6YGTRKDT.js";import{e as S}from"./chunk-UR6MHSHU.js";var e=S(K(),1);var r=S(O(),1);function V(n,x,c){return{id:n,label:`${x} (${n})`,isActive:n===c}}function se({resolver:n,currentProjectId:x,env:c,onSelect:w,onCancel:C}){let[q,B]=(0,e.useState)([]),[D,l]=(0,e.useState)(!0),[H,m]=(0,e.useState)(!1),[J,g]=(0,e.useState)(!1),[Q,P]=(0,e.useState)(null),[d,p]=(0,e.useState)("list"),[v,R]=(0,e.useState)(""),[E,h]=(0,e.useState)(null),[I,X]=(0,e.useState)(""),b=(0,e.useRef)(!1),A=(0,e.useRef)(!0);(0,e.useEffect)(()=>{if(!n){P("Login first to browse projects"),l(!1);return}let o=new AbortController,a=I.trim();return A.current?l(!0):a&&g(!0),m(!0),P(null),(async()=>{try{let t=n.cached??await n.resolve();if(!t){P("Login first to browse projects"),l(!1),m(!1),g(!1);return}let L=T(c),F=new k(L.tmsBaseUrl,t.username,t.access_key),f=!0,N=0,G=a?{signal:o.signal,name:a,perPage:10}:{signal:o.signal,perPage:10};for await(let y of F.listProjectsStream(G)){if(f&&(l(!1),g(!1),A.current=!1,f=!1),y.totalLoaded===0&&y.done&&N===0&&!a){b.current=!0,p("naming"),m(!1);return}let M=y.projects.map(j=>V(j.project_id,j.name,x));B(N===0?M:j=>[...j,...M]),N+=y.projects.length,y.done&&m(!1)}f&&(l(!1),m(!1),g(!1))}catch(t){if(t?.name==="AbortError")return;P(t instanceof Error?t.message:String(t)),l(!1),m(!1),g(!1)}})(),()=>o.abort()},[n,x,c,I]);let Y=(0,e.useCallback)(o=>{let a=o.trim();if(!a){h("Name cannot be empty");return}h(null),p("creating"),(async()=>{try{if(!n)throw new Error("Not authenticated");let t=n.cached??await n.resolve();if(!t)throw new Error("Not authenticated");let L=T(c),f=await new k(L.tmsBaseUrl,t.username,t.access_key).createProject(a);w(f.id,f.name)}catch(t){h(t instanceof Error?t.message:String(t)),p("naming")}})()},[n,c,w]),z=(0,e.useCallback)(()=>{R(""),h(null),b.current?C():p("list")},[C]);return d==="naming"||d==="creating"?(0,r.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:i.orange,paddingX:2,paddingY:1,children:[(0,r.jsx)(s,{color:i.orange,bold:!0,children:"Create new project"}),b.current&&(0,r.jsx)(u,{marginTop:1,children:(0,r.jsx)(s,{color:i.dim,children:"No projects yet \u2014 let's create one."})}),(0,r.jsxs)(u,{marginTop:1,children:[(0,r.jsx)(s,{color:i.dim,children:"Name: "}),d==="naming"?(0,r.jsx)($,{value:v,onChange:o=>{R(o),E&&h(null)},onSubmit:Y,onCancel:z}):(0,r.jsx)(s,{children:v})]}),E&&(0,r.jsx)(u,{marginTop:1,children:(0,r.jsx)(s,{color:i.red,children:E})}),d==="creating"&&(0,r.jsx)(u,{marginTop:1,children:(0,r.jsx)(s,{color:i.dim,children:"Creating..."})}),d==="naming"&&(0,r.jsx)(_,{bindings:[{keys:"\u21B5",label:"create"}],escBackLabel:b.current?"cancel":"back"})]}):(0,r.jsx)(U,{title:"Projects",items:q,loading:D,loadingMore:H,searching:J,preserveSelectionById:!0,onSearch:X,error:Q,itemNoun:"projects",onTab:()=>{b.current=!1,p("naming")},extraHint:"tab to create new",onSelect:o=>{let a=o.label.replace(` (${o.id})`,"");w(o.id,a)},onCancel:C})}export{V as a,se as b};
2
+ import{a as $}from"./chunk-YCCUBQY4.js";import{a as U}from"./chunk-FIODM24X.js";import{a as k}from"./chunk-BPMSNGXQ.js";import{a as _}from"./chunk-5NBT5IVT.js";import{a as T}from"./chunk-BE4FBVKY.js";import{x as i}from"./chunk-DEUDRSU7.js";import{a as O}from"./chunk-HCBYKLMW.js";import{a as u,b as s}from"./chunk-C44QQJR4.js";import{a as K}from"./chunk-6YGTRKDT.js";import{e as S}from"./chunk-UR6MHSHU.js";var e=S(K(),1);var r=S(O(),1);function V(n,x,c){return{id:n,label:`${x} (${n})`,isActive:n===c}}function se({resolver:n,currentProjectId:x,env:c,onSelect:w,onCancel:C}){let[q,B]=(0,e.useState)([]),[D,l]=(0,e.useState)(!0),[H,m]=(0,e.useState)(!1),[J,g]=(0,e.useState)(!1),[Q,P]=(0,e.useState)(null),[d,p]=(0,e.useState)("list"),[v,R]=(0,e.useState)(""),[E,h]=(0,e.useState)(null),[I,X]=(0,e.useState)(""),b=(0,e.useRef)(!1),A=(0,e.useRef)(!0);(0,e.useEffect)(()=>{if(!n){P("Login first to browse projects"),l(!1);return}let o=new AbortController,a=I.trim();return A.current?l(!0):a&&g(!0),m(!0),P(null),(async()=>{try{let t=n.cached??await n.resolve();if(!t){P("Login first to browse projects"),l(!1),m(!1),g(!1);return}let L=T(c),F=new k(L.tmsBaseUrl,t.username,t.access_key),f=!0,N=0,G=a?{signal:o.signal,name:a,perPage:10}:{signal:o.signal,perPage:10};for await(let y of F.listProjectsStream(G)){if(f&&(l(!1),g(!1),A.current=!1,f=!1),y.totalLoaded===0&&y.done&&N===0&&!a){b.current=!0,p("naming"),m(!1);return}let M=y.projects.map(j=>V(j.project_id,j.name,x));B(N===0?M:j=>[...j,...M]),N+=y.projects.length,y.done&&m(!1)}f&&(l(!1),m(!1),g(!1))}catch(t){if(t?.name==="AbortError")return;P(t instanceof Error?t.message:String(t)),l(!1),m(!1),g(!1)}})(),()=>o.abort()},[n,x,c,I]);let Y=(0,e.useCallback)(o=>{let a=o.trim();if(!a){h("Name cannot be empty");return}h(null),p("creating"),(async()=>{try{if(!n)throw new Error("Not authenticated");let t=n.cached??await n.resolve();if(!t)throw new Error("Not authenticated");let L=T(c),f=await new k(L.tmsBaseUrl,t.username,t.access_key).createProject(a);w(f.id,f.name)}catch(t){h(t instanceof Error?t.message:String(t)),p("naming")}})()},[n,c,w]),z=(0,e.useCallback)(()=>{R(""),h(null),b.current?C():p("list")},[C]);return d==="naming"||d==="creating"?(0,r.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:i.orange,paddingX:2,paddingY:1,children:[(0,r.jsx)(s,{color:i.orange,bold:!0,children:"Create new project"}),b.current&&(0,r.jsx)(u,{marginTop:1,children:(0,r.jsx)(s,{color:i.dim,children:"No projects yet \u2014 let's create one."})}),(0,r.jsxs)(u,{marginTop:1,children:[(0,r.jsx)(s,{color:i.dim,children:"Name: "}),d==="naming"?(0,r.jsx)($,{value:v,onChange:o=>{R(o),E&&h(null)},onSubmit:Y,onCancel:z}):(0,r.jsx)(s,{children:v})]}),E&&(0,r.jsx)(u,{marginTop:1,children:(0,r.jsx)(s,{color:i.red,children:E})}),d==="creating"&&(0,r.jsx)(u,{marginTop:1,children:(0,r.jsx)(s,{color:i.dim,children:"Creating..."})}),d==="naming"&&(0,r.jsx)(_,{bindings:[{keys:"\u21B5",label:"create"}],escBackLabel:b.current?"cancel":"back"})]}):(0,r.jsx)(U,{title:"Projects",items:q,loading:D,loadingMore:H,searching:J,preserveSelectionById:!0,onSearch:X,error:Q,itemNoun:"projects",onTab:()=>{b.current=!1,p("naming")},extraHint:"tab to create new",onSelect:o=>{let a=o.label.replace(` (${o.id})`,"");w(o.id,a)},onCancel:C})}export{V as a,se as b};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{c as u,d as p}from"./chunk-YHL5NA43.js";import{spawn as h}from"child_process";var k=new Set(["progress","ask_user","graph_query","ingest_request","proposal","design","error","done","reasoning_delta","reasoning_done","tool_activity","decision_activity","text_delta","usage","receipt","chat_ops","session_paused","session_complete","state_checkpoint"]);function v(g,n={}){let a=n.spawnCmd!==void 0?n.spawnCmd:u();if(!a)throw new Error("assurance agent not found \u2014 your platform package may be missing; reinstall kane-cli (npm i -g @testmuai/kane-cli)");let f=g.source.images?.length??0;a.tier==="dev-python"&&f>0&&n.onWarn?.("warn: development agent in use \u2014 if image citations are missing, update the agent package");let t=h(a.cmd,a.args,{stdio:["pipe","pipe","pipe"],env:p(g.session_id,n.auth)});if(t.stdin.write(JSON.stringify(g)+`
2
+ import{c as u,d as p}from"./chunk-G5ZGEZCA.js";import{spawn as h}from"child_process";var k=new Set(["progress","ask_user","graph_query","ingest_request","proposal","design","error","done","reasoning_delta","reasoning_done","tool_activity","decision_activity","text_delta","usage","receipt","chat_ops","session_paused","session_complete","state_checkpoint"]);function v(g,n={}){let a=n.spawnCmd!==void 0?n.spawnCmd:u();if(!a)throw new Error("assurance agent not found \u2014 your platform package may be missing; reinstall kane-cli (npm i -g @testmuai/kane-cli)");let f=g.source.images?.length??0;a.tier==="dev-python"&&f>0&&n.onWarn?.("warn: development agent in use \u2014 if image citations are missing, update the agent package");let t=h(a.cmd,a.args,{stdio:["pipe","pipe","pipe"],env:p(g.session_id,n.auth)});if(t.stdin.write(JSON.stringify(g)+`
3
3
  `),n.onStderr){let e="";t.stderr.on("data",r=>{e+=r.toString("utf8");let i;for(;(i=e.indexOf(`
4
4
  `))>=0;){let o=e.slice(0,i);e=e.slice(i+1),o.trim()&&n.onStderr(o)}})}let d=new Promise(e=>{t.on("exit",(r,i)=>e({code:r,signal:i}))});async function*m(){let e="",r=!1;for await(let i of t.stdout){e+=i.toString("utf8");let o;for(;(o=e.indexOf(`
5
5
  `))>=0;){let l=e.slice(0,o).trim();if(e=e.slice(o+1),!l)continue;let c;try{c=JSON.parse(l)}catch{n.onWarn?.(`agent: skipping malformed line: ${l.slice(0,120)}`);continue}let s=c;if(!s||typeof s!="object"||!k.has(s.type)){n.onWarn?.(`agent: skipping unknown event type "${s&&typeof s=="object"?String(s.type??"?"):"?"}"`);continue}if(yield s,s.type==="done"){r=!0;break}}if(r)break}await d.catch(()=>{})}return{events:m(),send:e=>{t.stdin&&!t.stdin.destroyed&&t.stdin.write(JSON.stringify(e)+`
@@ -1,17 +1,17 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{c as m}from"./chunk-VZ7KXRXB.js";import{a as _}from"./chunk-TDPWFYTJ.js";import{b as h}from"./chunk-WEJA3EVI.js";import{randomUUID as F}from"crypto";import{mkdirSync as A,writeFileSync as v,appendFileSync as O,existsSync as b}from"fs";import{join as u}from"path";import{writeFileSync as x,mkdirSync as I,existsSync as j}from"fs";import{join as p,relative as L}from"path";function f(n){let t=Object.keys(n.frontmatter).length>0?m(n.frontmatter).trimEnd():"",s=["---"];return t&&s.push(t),s.push("---",""),s.push(`# ${n.heading}`,""),n.steps.forEach((i,r)=>{s.push(`## Step ${r+1}`,i,"")}),s.join(`
3
- `)}function T(n,e){let t={},s={},i=e;for(let[r,l]of Object.entries(n)){if(r.startsWith("global.")||r.startsWith("secrets.user.")||r.startsWith("environment.")){let o=r.startsWith("secrets.user.");t[r]={value:l.value,secret:o,syntax:`{{${r}}}`,type:o?"secret":r.startsWith("environment.")?"environment":"global"},s[r]=r;continue}if(l.secret){let o=`secrets.user.${r}`;t[o]={value:l.value,secret:!0,syntax:`{{secrets.user.${r}}}`,type:"secret"},s[r]=o,i=i.replaceAll(`{{${r}}}`,`{{secrets.user.${r}}}`)}else{let o=`global.${r}`;t[o]={value:l.value,secret:!1,syntax:`{{global.${r}}}`,type:"global"},s[r]=o,i=i.replaceAll(`{{${r}}}`,`{{global.${r}}}`)}}return{variables:t,objective:i,keyMap:s}}var w=/\{\{\s*(?:global|secrets\.user|environment)\.([^{}]+?)\s*\}\}/g;function c(n){return typeof n!="string"||!n.includes("{{")?n:n.replace(w,"{{$1}}")}function d(n){if(typeof n=="string")return c(n);if(Array.isArray(n))return n.map(e=>d(e));if(n&&typeof n=="object"){let e={};for(let[t,s]of Object.entries(n))e[t]=d(s);return e}return n}var N=new Set(["username","access_key","oauth","profile","project_id","folder_id"]),$=new Set(["model","env"]),g=class{constructor(e){this.opts=e}objectives=[];flushed=!1;lastWrittenPath=null;lastCollisionSuffixed=!1;appendObjective(e){this.objectives.push(e)}flush(){if(this.flushed||(this.flushed=!0,this.objectives.length===0))return;let e=this.opts.getName();if(!e)return;let t=p(this.opts.cwd,".testmuai","tests");try{I(t,{recursive:!0})}catch(a){process.stderr.write(`
4
- \u26A0 Failed to create ${L(this.opts.cwd,t)}/
2
+ import{c as m}from"./chunk-VZ7KXRXB.js";import{a as _}from"./chunk-TDPWFYTJ.js";import{b as h}from"./chunk-DEUDRSU7.js";import{randomUUID as O}from"crypto";import{mkdirSync as D,writeFileSync as b,appendFileSync as A,existsSync as R}from"fs";import{join as u}from"path";import{writeFileSync as I,mkdirSync as j,existsSync as L}from"fs";import{join as p,relative as $}from"path";function f(n){let t=Object.keys(n.frontmatter).length>0?m(n.frontmatter).trimEnd():"",s=["---"];return t&&s.push(t),s.push("---",""),s.push(`# ${n.heading}`,""),n.steps.forEach((i,r)=>{s.push(`## Step ${r+1}`,i,"")}),s.join(`
3
+ `)}function v(n,e,t){let s=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return n.replace(new RegExp(`\\{\\{\\s*${s}(?=\\s*\\}\\}|[.\\[])`,"g"),`{{${t}.${e}`)}function U(n,e){let t={},s={},i=e;for(let[r,l]of Object.entries(n)){if(r.startsWith("global.")||r.startsWith("secrets.user.")||r.startsWith("environment.")){let o=r.startsWith("secrets.user.");t[r]={value:l.value,secret:o,syntax:`{{${r}}}`,type:o?"secret":r.startsWith("environment.")?"environment":"global"},s[r]=r;continue}if(l.secret){let o=`secrets.user.${r}`;t[o]={value:l.value,secret:!0,syntax:`{{secrets.user.${r}}}`,type:"secret"},s[r]=o,i=v(i,r,"secrets.user")}else{let o=`global.${r}`;t[o]={value:l.value,secret:!1,syntax:`{{global.${r}}}`,type:"global"},s[r]=o,i=v(i,r,"global")}}return{variables:t,objective:i,keyMap:s}}var x=/\{\{\s*(?:global|secrets\.user|environment)\.([^{}]+?)\s*\}\}/g;function c(n){return typeof n!="string"||!n.includes("{{")?n:n.replace(x,"{{$1}}")}function d(n){if(typeof n=="string")return c(n);if(Array.isArray(n))return n.map(e=>d(e));if(n&&typeof n=="object"){let e={};for(let[t,s]of Object.entries(n))e[t]=d(s);return e}return n}var N=new Set(["username","access_key","oauth","profile","project_id","folder_id"]),E=new Set(["model","env"]),g=class{constructor(e){this.opts=e}objectives=[];flushed=!1;lastWrittenPath=null;lastCollisionSuffixed=!1;appendObjective(e){this.objectives.push(e)}flush(){if(this.flushed||(this.flushed=!0,this.objectives.length===0))return;let e=this.opts.getName();if(!e)return;let t=p(this.opts.cwd,".testmuai","tests");try{j(t,{recursive:!0})}catch(a){process.stderr.write(`
4
+ \u26A0 Failed to create ${$(this.opts.cwd,t)}/
5
5
  ${a.message}
6
6
  Your test recording was NOT saved.
7
7
 
8
- `);return}let s=p(t,`${e}_test.md`),i=2,r=!1;for(;j(s);)s=p(t,`${e}-${i}_test.md`),i++,r=!0;let l=d(E(this.opts.getResolvedGlobal())),o=f({frontmatter:l,heading:`Session: ${e}`,steps:this.objectives.map(c)});try{x(s,o,"utf8")}catch(a){process.stderr.write(`
8
+ `);return}let s=p(t,`${e}_test.md`),i=2,r=!1;for(;L(s);)s=p(t,`${e}-${i}_test.md`),i++,r=!0;let l=d(F(this.opts.getResolvedGlobal())),o=f({frontmatter:l,heading:`Session: ${e}`,steps:this.objectives.map(c)});try{I(s,o,"utf8")}catch(a){process.stderr.write(`
9
9
  \u26A0 Failed to save your test recording.
10
10
  ${a.message}
11
11
  Path: ${s}
12
12
 
13
- `);return}this.lastWrittenPath=s,this.lastCollisionSuffixed=r}};function E(n){let e={};for(let[t,s]of Object.entries(n))N.has(t)||$.has(t)||(e[t]=s);return e}var D=u(h,"sessions"),R=class{sessionId;sessionDir;runs=[];_flows=[];_nextIndex=0;_started=!1;_testId=null;_testcaseId=null;_projectId=null;_orgId=null;_userName=null;_userEmail=null;_uploadStatus="pending";_uploadAttempts=0;_uploadError=null;_firstObjective=null;_firstUrl=null;_auteurVariables={};_screenshotSas=null;_model="";_environment="";_profile=null;_plan=null;_startedAt="";_remoteLogger=null;_earlyLogBuffer=[];_recorder=null;_resolvedGlobal={};_sessionName=null;_recordingEnabled=!0;_stepRunRecords=[];constructor(e){this.sessionId=F();let t=e?.baseDir?u(e.baseDir,"sessions"):D;this.sessionDir=u(t,this.sessionId)}setResolvedGlobal(e){this._resolvedGlobal={...this._resolvedGlobal,...e}}setSessionName(e){this._sessionName=e}get sessionName(){return this._sessionName}setRecordingEnabled(e){this._recordingEnabled=e}get recorder(){return this._recorder}flushRecorder(){try{this._recorder?.flush()}catch(e){process.stderr.write(`[recorder] flush failed: ${e.message}
14
- `)}}start(e){if(!this._started){this._started=!0,this._model=e.model,this._environment=e.environment,this._profile=e.profile,this._startedAt=new Date().toISOString();try{A(this.sessionDir,{recursive:!0}),this._recorder=new g({cwd:process.cwd(),getResolvedGlobal:()=>this._resolvedGlobal,getName:()=>this._sessionName});let t={session_id:this.sessionId,started_at:this._startedAt,model:e.model,environment:e.environment,profile:e.profile,plan:this._plan,objectives:[],runs:[],status:"in_progress"};v(u(this.sessionDir,"session.json"),JSON.stringify(t,null,2)+`
15
- `)}catch{}this._log(`SESSION START session_id=${this.sessionId}`),this._log(`CONFIG model=${e.model} env=${e.environment} profile=${e.profile}`),this._earlyLogBuffer.push({level:"info",event:"SESSION_START",message:"Session started",context:{session_id:this.sessionId}},{level:"info",event:"CONFIG",message:"Session config",context:{model:e.model,environment:e.environment,profile:e.profile}})}}setPlan(e){this._plan=e;let t={level:"info",event:"SESSION_INFO",message:"Session info",context:{session_id:this.sessionId,plan:e??null}};this._remoteLogger?this._remoteLogger.log(t.level,t.event,t.message,t.context):this._earlyLogBuffer.push(t)}get plan(){return this._plan}get apMode(){return _()??"v2"}setRemoteLogger(e){this._remoteLogger=e;for(let t of this._earlyLogBuffer)e.log(t.level,t.event,t.message,t.context);this._earlyLogBuffer=[]}get hasRemoteLogger(){return this._remoteLogger!==null}setAuteurVariables(e){Object.assign(this._auteurVariables,e)}get auteurVariables(){return this._auteurVariables}setScreenshotSas(e){this._screenshotSas=e}get screenshotSas(){return this._screenshotSas}get screenshotBaseUrl(){return this._screenshotSas?`${this._screenshotSas.base_url}/${this._screenshotSas.container}`:""}get startedAt(){return this._startedAt||new Date().toISOString()}log(e,t,s,i){if(t===void 0){this._log(e);let o=e.indexOf(" "),a=o>0?e.slice(0,o):e,S=o>0?e.slice(o+1):"",y=/fail|error/i.test(e)?"error":"info";this._remoteLogger?.log(y,a,S||e);return}let r=e,l=s;this._log(`${t} ${l}`,i),this._remoteLogger?.log(r,t,l,i)}logStep(e,t,s){this._log(`${e} ${t}`,s);let i=this._nextIndex>0?this._nextIndex-1:0;this._remoteLogger?.logStep(i,e,t,s)}logCommand(e){this._log(`COMMAND ${e}`)}logRunStart(e,t,s){this._log(`RUN ${e} START objective="${t.slice(0,100)}" url=${s}`),this._remoteLogger?.setRunIndex(e),this._remoteLogger?.log("info","RUN_START",`Run ${e} started`,{run_index:e,objective:t,url:s})}logRunEnd(e,t,s,i,r){let l=(s??0).toFixed(1),o=(i??"").slice(0,100),a=r==null||r===""||Number.isNaN(Number(r))?null:Number(r);this._log(`RUN ${e} END status=${t} duration=${l}s summary="${o}"`,a!=null?{result_code:a}:void 0),this._remoteLogger?.log("info","RUN_END",`Run ${e} ended`,{run_index:e,status:t,duration:s??0,summary:i??"",result_code:a}),t!=="failed"&&t!=="error"&&this._remoteLogger?.discardSteps(e)}escalateRun(e){this._remoteLogger?.escalate(e)}logChromeLaunch(e,t){this._log(`CHROME LAUNCH port=${e} endpoint=${t}`),this._remoteLogger?.log("info","CHROME_LAUNCH","Chrome launched",{port:e,cdp_endpoint:t})}async finish(e="complete"){this._log(`SESSION END status=${e} total_runs=${this.runs.length}`),this._remoteLogger?.log("info","SESSION_END","Session ended",{status:e,total_runs:this.runs.length}),await this._remoteLogger?.shutdown();let t={session_id:this.sessionId,started_at:this._startedAt,ended_at:new Date().toISOString(),model:this._model,environment:this._environment,profile:this._profile,plan:this._plan,status:e,total_runs:this.runs.length,test_id:this._testId,testcase_id:this._testcaseId,commit_id:this.sessionId,project_id:this._projectId,upload_status:this._uploadStatus,upload_attempts:this._uploadAttempts,last_upload_attempt:this._uploadAttempts>0?new Date().toISOString():null,upload_error:this._uploadError,runs:this.runs.map(s=>({index:s.index,objective:s.objective,status:s.status,summary:s.summary,run_dir:s.run_dir}))};b(this.sessionDir)&&v(u(this.sessionDir,"session.json"),JSON.stringify(t,null,2)+`
16
- `),this.flushRecorder(),this._recorder=null}nextRunIndex(){return this._nextIndex}addRunResult(e,t){this.runs.push(e),this._nextIndex+=t??1,this._recordingEnabled&&this._recorder?.appendObjective(e.objective)}getContext(){return{prior_runs:this.runs.map(e=>({index:e.index,objective:e.objective,summary:e.summary,status:e.status,memory:e.context.memory,variables:e.context.variables,pointer:e.context.pointer}))}}addFlow(e){let t={...e,index:this._flows.length+1};return this._flows.push(t),t}getFlows(){return[...this._flows]}getFlow(e){return this._flows.find(t=>t.index===e)}clearFlows(){this._flows=[]}recordStepRun(e){this._stepRunRecords.push(e)}getStepRunRecords(){return[...this._stepRunRecords]}getRunsAsStepRecords(){return this.runs.map((e,t)=>({testmdStepIndex:t+1,runIndex:e.index,totalRunDirs:e.run_dirs?.length??1}))}snapshot(){return{runsLen:this.runs.length,nextRunIndex:this._nextIndex,stepRunRecordsLen:this._stepRunRecords.length}}rollback(e){this.runs.length=e.runsLen,this._nextIndex=e.nextRunIndex,this._stepRunRecords.length=e.stepRunRecordsLen}setTestId(e){this._testId=e}get testId(){return this._testId}setTestcaseId(e){this._testcaseId=e}get testcaseId(){return this._testcaseId}setProjectId(e){this._projectId=e}setOrgId(e){this._orgId=e}get orgId(){return this._orgId}setUserIdentity(e,t){e&&(this._userName=e),t&&(this._userEmail=t)}get userName(){return this._userName}get userEmail(){return this._userEmail}setFirstRun(e,t){this._firstObjective||(this._firstObjective=e,this._firstUrl=t)}get firstObjective(){return this._firstObjective}get firstUrl(){return this._firstUrl}getRunDirs(){let e=[];for(let t of this.runs)t.run_dirs&&t.run_dirs.length>0?e.push(...t.run_dirs):t.run_dir&&e.push(t.run_dir);return e}getRunObjectives(){let e=[];for(let t of this.runs)t.flow_objectives&&t.flow_objectives.length>0?e.push(...t.flow_objectives):e.push(t.objective);return e}getRunMetadata(){let e=[];for(let t of this.runs)if(t.perFlowMetadata&&t.perFlowMetadata.length>0)e.push(...t.perFlowMetadata);else{let s={resultCode:t.resultCode,reasonCode:t.reasonCode,errorMessage:t.status==="failed"?t.summary??null:null,summary:t.summary,oneLiner:t.oneLiner},i=t.run_dirs?.length??1;for(let r=0;r<i;r++)e.push(s)}return e}setUploadStatus(e,t){this._uploadStatus=e,this._uploadAttempts+=1,this._uploadError=t??null}_log(e,t){if(!(!this._started||!b(this.sessionDir)))try{let s=new Date().toISOString().slice(0,19).replace("T"," "),i=u(this.sessionDir,"tui.log"),r=t&&Object.keys(t).length>0?` ${JSON.stringify(t)}`:"";O(i,`[${s}] ${e}${r}
17
- `)}catch{}}};export{f as a,T as b,R as c};
13
+ `);return}this.lastWrittenPath=s,this.lastCollisionSuffixed=r}};function F(n){let e={};for(let[t,s]of Object.entries(n))N.has(t)||E.has(t)||(e[t]=s);return e}var k=u(h,"sessions"),S=class{sessionId;sessionDir;runs=[];_flows=[];_nextIndex=0;_started=!1;_testId=null;_testcaseId=null;_projectId=null;_orgId=null;_userName=null;_userEmail=null;_uploadStatus="pending";_uploadAttempts=0;_uploadError=null;_firstObjective=null;_firstUrl=null;_auteurVariables={};_screenshotSas=null;_model="";_environment="";_profile=null;_plan=null;_startedAt="";_remoteLogger=null;_earlyLogBuffer=[];_recorder=null;_resolvedGlobal={};_sessionName=null;_recordingEnabled=!0;_stepRunRecords=[];constructor(e){this.sessionId=O();let t=e?.baseDir?u(e.baseDir,"sessions"):k;this.sessionDir=u(t,this.sessionId)}setResolvedGlobal(e){this._resolvedGlobal={...this._resolvedGlobal,...e}}setSessionName(e){this._sessionName=e}get sessionName(){return this._sessionName}setRecordingEnabled(e){this._recordingEnabled=e}get recorder(){return this._recorder}flushRecorder(){try{this._recorder?.flush()}catch(e){process.stderr.write(`[recorder] flush failed: ${e.message}
14
+ `)}}start(e){if(!this._started){this._started=!0,this._model=e.model,this._environment=e.environment,this._profile=e.profile,this._startedAt=new Date().toISOString();try{D(this.sessionDir,{recursive:!0}),this._recorder=new g({cwd:process.cwd(),getResolvedGlobal:()=>this._resolvedGlobal,getName:()=>this._sessionName});let t={session_id:this.sessionId,started_at:this._startedAt,model:e.model,environment:e.environment,profile:e.profile,plan:this._plan,objectives:[],runs:[],status:"in_progress"};b(u(this.sessionDir,"session.json"),JSON.stringify(t,null,2)+`
15
+ `)}catch{}this._log(`SESSION START session_id=${this.sessionId}`),this._log(`CONFIG model=${e.model} env=${e.environment} profile=${e.profile}`),this._earlyLogBuffer.push({level:"info",event:"SESSION_START",message:"Session started",context:{session_id:this.sessionId}},{level:"info",event:"CONFIG",message:"Session config",context:{model:e.model,environment:e.environment,profile:e.profile}})}}setPlan(e){this._plan=e;let t={level:"info",event:"SESSION_INFO",message:"Session info",context:{session_id:this.sessionId,plan:e??null}};this._remoteLogger?this._remoteLogger.log(t.level,t.event,t.message,t.context):this._earlyLogBuffer.push(t)}get plan(){return this._plan}get apMode(){return _()??"v2"}setRemoteLogger(e){this._remoteLogger=e;for(let t of this._earlyLogBuffer)e.log(t.level,t.event,t.message,t.context);this._earlyLogBuffer=[]}get hasRemoteLogger(){return this._remoteLogger!==null}setAuteurVariables(e){Object.assign(this._auteurVariables,e)}get auteurVariables(){return this._auteurVariables}setScreenshotSas(e){this._screenshotSas=e}get screenshotSas(){return this._screenshotSas}get screenshotBaseUrl(){return this._screenshotSas?`${this._screenshotSas.base_url}/${this._screenshotSas.container}`:""}get startedAt(){return this._startedAt||new Date().toISOString()}log(e,t,s,i){if(t===void 0){this._log(e);let o=e.indexOf(" "),a=o>0?e.slice(0,o):e,y=o>0?e.slice(o+1):"",w=/fail|error/i.test(e)?"error":"info";this._remoteLogger?.log(w,a,y||e);return}let r=e,l=s;this._log(`${t} ${l}`,i),this._remoteLogger?.log(r,t,l,i)}logStep(e,t,s){this._log(`${e} ${t}`,s);let i=this._nextIndex>0?this._nextIndex-1:0;this._remoteLogger?.logStep(i,e,t,s)}logCommand(e){this._log(`COMMAND ${e}`)}logRunStart(e,t,s){this._log(`RUN ${e} START objective="${t.slice(0,100)}" url=${s}`),this._remoteLogger?.setRunIndex(e),this._remoteLogger?.log("info","RUN_START",`Run ${e} started`,{run_index:e,objective:t,url:s})}logRunEnd(e,t,s,i,r){let l=(s??0).toFixed(1),o=(i??"").slice(0,100),a=r==null||r===""||Number.isNaN(Number(r))?null:Number(r);this._log(`RUN ${e} END status=${t} duration=${l}s summary="${o}"`,a!=null?{result_code:a}:void 0),this._remoteLogger?.log("info","RUN_END",`Run ${e} ended`,{run_index:e,status:t,duration:s??0,summary:i??"",result_code:a}),t!=="failed"&&t!=="error"&&this._remoteLogger?.discardSteps(e)}escalateRun(e){this._remoteLogger?.escalate(e)}logChromeLaunch(e,t){this._log(`CHROME LAUNCH port=${e} endpoint=${t}`),this._remoteLogger?.log("info","CHROME_LAUNCH","Chrome launched",{port:e,cdp_endpoint:t})}async finish(e="complete"){this._log(`SESSION END status=${e} total_runs=${this.runs.length}`),this._remoteLogger?.log("info","SESSION_END","Session ended",{status:e,total_runs:this.runs.length}),await this._remoteLogger?.shutdown();let t={session_id:this.sessionId,started_at:this._startedAt,ended_at:new Date().toISOString(),model:this._model,environment:this._environment,profile:this._profile,plan:this._plan,status:e,total_runs:this.runs.length,test_id:this._testId,testcase_id:this._testcaseId,commit_id:this.sessionId,project_id:this._projectId,upload_status:this._uploadStatus,upload_attempts:this._uploadAttempts,last_upload_attempt:this._uploadAttempts>0?new Date().toISOString():null,upload_error:this._uploadError,runs:this.runs.map(s=>({index:s.index,objective:s.objective,status:s.status,summary:s.summary,run_dir:s.run_dir}))};R(this.sessionDir)&&b(u(this.sessionDir,"session.json"),JSON.stringify(t,null,2)+`
16
+ `),this.flushRecorder(),this._recorder=null}nextRunIndex(){return this._nextIndex}addRunResult(e,t){this.runs.push(e),this._nextIndex+=t??1,this._recordingEnabled&&this._recorder?.appendObjective(e.objective)}getContext(){return{prior_runs:this.runs.map(e=>({index:e.index,objective:e.objective,summary:e.summary,status:e.status,memory:e.context.memory,variables:e.context.variables,pointer:e.context.pointer}))}}addFlow(e){let t={...e,index:this._flows.length+1};return this._flows.push(t),t}getFlows(){return[...this._flows]}getFlow(e){return this._flows.find(t=>t.index===e)}clearFlows(){this._flows=[]}recordStepRun(e){this._stepRunRecords.push(e)}getStepRunRecords(){return[...this._stepRunRecords]}getRunsAsStepRecords(){return this.runs.map((e,t)=>({testmdStepIndex:t+1,runIndex:e.index,totalRunDirs:e.run_dirs?.length??1}))}snapshot(){return{runsLen:this.runs.length,nextRunIndex:this._nextIndex,stepRunRecordsLen:this._stepRunRecords.length}}rollback(e){this.runs.length=e.runsLen,this._nextIndex=e.nextRunIndex,this._stepRunRecords.length=e.stepRunRecordsLen}setTestId(e){this._testId=e}get testId(){return this._testId}setTestcaseId(e){this._testcaseId=e}get testcaseId(){return this._testcaseId}setProjectId(e){this._projectId=e}setOrgId(e){this._orgId=e}get orgId(){return this._orgId}setUserIdentity(e,t){e&&(this._userName=e),t&&(this._userEmail=t)}get userName(){return this._userName}get userEmail(){return this._userEmail}setFirstRun(e,t){this._firstObjective||(this._firstObjective=e,this._firstUrl=t)}get firstObjective(){return this._firstObjective}get firstUrl(){return this._firstUrl}getRunDirs(){let e=[];for(let t of this.runs)t.run_dirs&&t.run_dirs.length>0?e.push(...t.run_dirs):t.run_dir&&e.push(t.run_dir);return e}getRunObjectives(){let e=[];for(let t of this.runs)t.flow_objectives&&t.flow_objectives.length>0?e.push(...t.flow_objectives):e.push(t.objective);return e}getRunMetadata(){let e=[];for(let t of this.runs)if(t.perFlowMetadata&&t.perFlowMetadata.length>0)e.push(...t.perFlowMetadata);else{let s={resultCode:t.resultCode,reasonCode:t.reasonCode,errorMessage:t.status==="failed"?t.summary??null:null,summary:t.summary,oneLiner:t.oneLiner},i=t.run_dirs?.length??1;for(let r=0;r<i;r++)e.push(s)}return e}setUploadStatus(e,t){this._uploadStatus=e,this._uploadAttempts+=1,this._uploadError=t??null}_log(e,t){if(!(!this._started||!R(this.sessionDir)))try{let s=new Date().toISOString().slice(0,19).replace("T"," "),i=u(this.sessionDir,"tui.log"),r=t&&Object.keys(t).length>0?` ${JSON.stringify(t)}`:"";A(i,`[${s}] ${e}${r}
17
+ `)}catch{}}};export{f as a,U as b,S as c};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as B}from"./chunk-S3DAAAE5.js";import{a as g}from"./chunk-ZFZB4CGJ.js";import{x as s}from"./chunk-WEJA3EVI.js";import{a as w}from"./chunk-HCBYKLMW.js";import{a as x,b as t,c as h,i as P,j as S}from"./chunk-C44QQJR4.js";import{a as C}from"./chunk-6YGTRKDT.js";import{e as T}from"./chunk-UR6MHSHU.js";var o=T(C(),1);var e=T(w(),1);function D({defaultName:i,onSubmit:c}){let[d,p]=(0,o.useState)("confirm"),[f,a]=(0,o.useState)(""),[m,u]=(0,o.useState)(null),l=(0,o.useMemo)(()=>f.trim()||i,[f,i]);return P((n,r)=>{if(d==="confirm"){if(n==="y"||n==="Y"){a(i),p("name");return}if(n==="n"||n==="N"||r.escape||r.ctrl&&n==="c"){c(null);return}if(r.return){c(i);return}return}if(r.return){if(!B(l)){u(`name "${l}" is invalid; allowed: letters, digits, underscore, hyphen`);return}c(l);return}if(r.escape||r.ctrl&&n==="c"){c(null);return}if(r.backspace||r.delete){a(v=>v.slice(0,-1)),u(null);return}n&&!r.ctrl&&!r.meta&&(a(v=>v+n),u(null))}),d==="confirm"?(0,e.jsx)(g,{title:"Save session?",titleColor:"#ff9500",rows:[{label:"name",value:(0,e.jsx)(t,{color:s.orange,children:i})}],footer:(0,e.jsxs)(x,{flexDirection:"column",children:[(0,e.jsx)(t,{color:s.dim,children:"enter \u2014 save with this name"}),(0,e.jsx)(t,{color:s.dim,children:"Y \u2014 edit name"}),(0,e.jsx)(t,{color:s.dim,children:"N/esc \u2014 discard session"})]})}):(0,e.jsx)(g,{title:"Save session?",titleColor:"#ff9500",rows:[{label:"name",value:(0,e.jsxs)(x,{children:[(0,e.jsx)(t,{color:s.orange,children:f}),(0,e.jsx)(t,{inverse:!0,children:" "})]})}],footer:(0,e.jsxs)(x,{flexDirection:"column",children:[m&&(0,e.jsx)(t,{color:s.red,children:m}),(0,e.jsx)(t,{color:s.dim,children:"enter \u2014 save \xB7 esc \u2014 discard"})]})})}function V(){return new Date().toISOString().slice(0,19).replace(/:/g,"-")}async function Y(i){return new Promise(c=>{function d(){let{exit:a}=S(),[m,u]=(0,o.useState)(!1);return(0,o.useEffect)(()=>{if(m){let l=setTimeout(()=>a(),50);return()=>clearTimeout(l)}},[m,a]),(0,e.jsx)(D,{defaultName:i,onSubmit:l=>{c(l),u(!0)}})}let{waitUntilExit:p,unmount:f}=h((0,e.jsx)(d,{}),{stdout:process.stderr,exitOnCtrlC:!1});p().then(()=>{try{f()}catch{}})})}export{D as a,V as b,Y as c};
2
+ import{b as B}from"./chunk-S3DAAAE5.js";import{a as g}from"./chunk-6DOS5CJ5.js";import{x as s}from"./chunk-DEUDRSU7.js";import{a as w}from"./chunk-HCBYKLMW.js";import{a as x,b as t,c as h,i as P,j as S}from"./chunk-C44QQJR4.js";import{a as C}from"./chunk-6YGTRKDT.js";import{e as T}from"./chunk-UR6MHSHU.js";var o=T(C(),1);var e=T(w(),1);function D({defaultName:i,onSubmit:c}){let[d,p]=(0,o.useState)("confirm"),[f,a]=(0,o.useState)(""),[m,u]=(0,o.useState)(null),l=(0,o.useMemo)(()=>f.trim()||i,[f,i]);return P((n,r)=>{if(d==="confirm"){if(n==="y"||n==="Y"){a(i),p("name");return}if(n==="n"||n==="N"||r.escape||r.ctrl&&n==="c"){c(null);return}if(r.return){c(i);return}return}if(r.return){if(!B(l)){u(`name "${l}" is invalid; allowed: letters, digits, underscore, hyphen`);return}c(l);return}if(r.escape||r.ctrl&&n==="c"){c(null);return}if(r.backspace||r.delete){a(v=>v.slice(0,-1)),u(null);return}n&&!r.ctrl&&!r.meta&&(a(v=>v+n),u(null))}),d==="confirm"?(0,e.jsx)(g,{title:"Save session?",titleColor:"#ff9500",rows:[{label:"name",value:(0,e.jsx)(t,{color:s.orange,children:i})}],footer:(0,e.jsxs)(x,{flexDirection:"column",children:[(0,e.jsx)(t,{color:s.dim,children:"enter \u2014 save with this name"}),(0,e.jsx)(t,{color:s.dim,children:"Y \u2014 edit name"}),(0,e.jsx)(t,{color:s.dim,children:"N/esc \u2014 discard session"})]})}):(0,e.jsx)(g,{title:"Save session?",titleColor:"#ff9500",rows:[{label:"name",value:(0,e.jsxs)(x,{children:[(0,e.jsx)(t,{color:s.orange,children:f}),(0,e.jsx)(t,{inverse:!0,children:" "})]})}],footer:(0,e.jsxs)(x,{flexDirection:"column",children:[m&&(0,e.jsx)(t,{color:s.red,children:m}),(0,e.jsx)(t,{color:s.dim,children:"enter \u2014 save \xB7 esc \u2014 discard"})]})})}function V(){return new Date().toISOString().slice(0,19).replace(/:/g,"-")}async function Y(i){return new Promise(c=>{function d(){let{exit:a}=S(),[m,u]=(0,o.useState)(!1);return(0,o.useEffect)(()=>{if(m){let l=setTimeout(()=>a(),50);return()=>clearTimeout(l)}},[m,a]),(0,e.jsx)(D,{defaultName:i,onSubmit:l=>{c(l),u(!0)}})}let{waitUntilExit:p,unmount:f}=h((0,e.jsx)(d,{}),{stdout:process.stderr,exitOnCtrlC:!1});p().then(()=>{try{f()}catch{}})})}export{D as a,V as b,Y as c};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{existsSync as i,renameSync as s,rmSync as o}from"fs";function u(r){let e=`${r}.staging`,c=`${r}.bak`;if(!i(e))throw new Error(`atomicReplaceDir: staging missing: ${e}`);if(process.platform==="win32"){i(r)&&o(r,{recursive:!0,force:!0}),s(e,r);return}i(r)&&(i(c)&&o(c,{recursive:!0,force:!0}),s(r,c)),s(e,r),i(c)&&o(c,{recursive:!0,force:!0})}function f(r){let e=`${r}.staging`,c=`${r}.bak`;if(process.platform==="win32"){i(e)&&(i(r)?o(e,{recursive:!0,force:!0}):s(e,r));return}if(i(c)&&!i(r)){s(c,r),i(e)&&o(e,{recursive:!0,force:!0});return}i(c)&&i(r)&&o(c,{recursive:!0,force:!0}),i(e)&&i(r)&&o(e,{recursive:!0,force:!0})}export{u as a,f as b};
@@ -0,0 +1,6 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{b as y}from"./chunk-WD52ZNQY.js";import{b as l,d,e as m,g,h as S}from"./chunk-T4OJX2GZ.js";import{a as f}from"./chunk-7KRCBN6X.js";import{r as u,s as p}from"./chunk-RSSOJ3L2.js";import{existsSync as s,mkdirSync as h,readFileSync as C,renameSync as w,writeFileSync as R}from"fs";import{join as x}from"path";function G(e){y(l(e));let r=l(e);if(!s(r))return;let n=x(r,"meta.json"),o=m(e);if(s(n)&&!s(o))try{h(d(e),{recursive:!0}),w(n,o)}catch(t){process.stderr.write(`warn: meta.json migration failed: ${t.message}
3
+ `)}let a=S(e);if(s(a)){let t="python";try{let i=new f().load();i.code_export?.language&&(t=i.code_export.language)}catch{}let c=g(e,"playwright",t);if(!s(c))try{w(a,c)}catch(i){process.stderr.write(`warn: generated-code migration failed: ${i.message}
4
+ `)}}if(s(o))try{let t=JSON.parse(C(o,"utf8"));"md5sum"in t&&(delete t.md5sum,R(o,JSON.stringify(t,null,2)+`
5
+ `,"utf8"))}catch(t){process.stderr.write(`warn: meta.json md5sum strip failed: ${t.message}
6
+ `)}}async function O(e){if(!e.isInteractive)return{recovered:!1};if(E(e.creds))return{recovered:!1};let{SingleShotApp:r}=await import("./SingleShotApp-KXZF5ZJM.js"),{ScrollbackProvider:n}=await import("./scrollback-JLPJR25X.js"),{render:o}=await import("./build-JIKYOZUH.js"),a=await import("./react-QWOAB3TB.js"),t={current:null},c={current:!1},{waitUntilExit:i,unmount:v}=o(a.default.createElement(n,null,a.default.createElement(r,{resultRef:t,mode:"login",loginCompleteRef:c})),{exitOnCtrlC:!1});p(()=>v()),await i();try{process.stdin.setRawMode?.(!1)}catch{}return process.stdout.write("\x1B[?25h"),c.current?{recovered:!0}:(u(0,"Startup gate cancelled"),{recovered:!1})}function E(e){let r=e.getActiveProfile(),n=e.getDefaultEnv();if(!r||!!!(e.loadBasicAuth(r,n)||e.loadCredentials(r,n)))return!1;let a=e.loadProfileConfig(r,n)??{};return!!a.project_id&&!!a.folder_id}export{G as a,O as b};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as S}from"./chunk-I7TIGB7K.js";import{a as x,b as P,c as C,d as V,e as j}from"./chunk-C33E5XQM.js";import{a as R,b as D}from"./chunk-DNNZ353O.js";import{C as y,c as b,r as f,s as k}from"./chunk-W3Z7AZNT.js";import{e as w}from"./chunk-DBIBROYW.js";function I(o,t){return{contextDir:o,rootSid:t,locks:w(o,t),probe:S(o,{resolveAlias:i=>P(i),embed:(i,s)=>C(i,s),readVector:(i,s)=>V(o,i,s),writeVector:(i,s,n)=>j(o,i,s,n)})}}var N=new Set(["archive"]);async function Y(o,t,i,s){let n=y(o.contextDir);if(i.v==="defer")return{outcome:"deferred"};if(t.kind==="MODIFY_HELD"){if(!t.heldPayload)return{outcome:"failed",detail:`${t.ref} carries no held payload`};let e=t.heldPayload;if(i.v==="keep_current"){if(!e.event_id)return{outcome:"failed",detail:`this held row has no durable event id \u2014 resume the owner to drop it: kane-cli context extract --resume ${e.sid}`};let{commitChatTurn:r}=await import("./chat-committer-K3NOTLOU.js"),u=r({contextDir:o.contextDir,graph:n,ops:[{kind:"resolve_question",questionId:`drop-held:${e.sid}:${e.tempRef}`,resolution:"deferred",eventId:e.event_id}],by:s});return u.errors?{outcome:"failed",detail:u.errors.map(d=>`${d.code}: ${d.detail}`).join("; ")}:(o.signals?.({ref:t.ref,verdict:"held-dropped"}),{outcome:"committed",detail:"held payload dropped (recorded) \u2014 the owner's resume will not re-present it"})}if(i.v==="approve"){let r=e.content._held??null;if(!r?.source_id||!r.source_cid||!r.anchor||!r.quote)return{outcome:"failed",detail:`this held row carries no committable provenance \u2014 resume the owner to apply it: kane-cli context extract --resume ${e.sid}`};{let a=n.mediaOf(r.source_cid),m=R(o.contextDir,n,r.source_cid),g=a.format==="image"?null:m?D(m):null;if(a.format!=="image"&&g===null)return{outcome:"failed",detail:`the pinned source ${r.source_id} (${r.source_cid.slice(0,19)}) has no citable text to verify this held row against \u2014 resume the owner: kane-cli context extract --resume ${e.sid}`};let _=b(a,{anchor:r.anchor,quote:r.quote},g);if(_.length>0)return{outcome:"failed",detail:`held provenance does not verify against the pinned source (${_.map($=>`${$.code}: ${$.detail}`).join("; ")}) \u2014 resume the owner: kane-cli context extract --resume ${e.sid}`}}let{commitProposal:u}=await import("./committer-C6UCDYMC.js"),{_held:d,...c}=e.content,q={version:1,read_basis:n.latestHash,source:{source_id:r.source_id,source_cid:r.source_cid},use_cases:[{temp_ref:e.tempRef,title:String(c.title??e.tempRef),...c.summary!==void 0?{summary:c.summary}:{},risk:String(c.risk??"med"),cite:{anchor:r.anchor,quote:r.quote},depends_on_hint:[],matches_existing:null}]},l=await x(I(o.contextDir,o.rootSid??`review-${process.pid}`),{verb:"maintain",ucTargets:[],newBuCandidates:[{tempRef:e.tempRef,title:String(c.title??e.tempRef),probeText:`${String(c.title??"")} ${String(c.summary??"")}`.trim()}],sourcePins:[{source_id:r.source_id,source_cid:r.source_cid}],readBasis:n.latestHash,...e.event_id?{eventIds:[e.event_id]}:{}},a=>{let m=u({contextDir:o.contextDir,graph:a.graph,proposal:q,proposalId:null,verdicts:new Map([[e.tempRef,{resolution:"skipped"}]]),by:s,autoName:!0,allowStaleBasis:!0,eventIds:e.event_id?[e.event_id]:a.eventIds("maintain",1),sid:a.sid,probeHits:a.probeHits});return m.errors!==null?{errors:m.errors}:{result:m,record:m.record}}),h=l.ok&&"result"in l?l.result:{record:null,errors:l.ok?null:l.kind==="validation"?l.errors:[{code:l.kind==="contended"?l.err.code:"UNSETTLED",detail:l.kind==="contended"?`held by ${l.err.holder?.owner_sid??"another session"}`:"concurrent activity kept moving the store"}]};return h.errors?{outcome:"failed",detail:h.errors.map(a=>`${a.code}: ${a.detail}`).join("; ")}:(o.signals?.({ref:t.ref,verdict:"held-applied"}),{outcome:"committed",detail:`held payload committed (derived) by ${s.id}`})}return{outcome:"failed",detail:`verdict ${i.v} does not apply to a MODIFY_HELD card`}}let v=n.resolve(t.ref);if(!v)return{outcome:"failed",detail:`${t.ref} names nothing in the graph`};let p=n.tipOf(v.cid);if(i.v==="archive"){if(!i.because||!i.because.trim())return{outcome:"failed",detail:"archive requires --because (a reason the record keeps)"};let e=f({contextDir:o.contextDir,graph:n,verdicts:new Map([[p,{resolution:"rejected",reason:i.because}]]),by:s});return e.errors?{outcome:"failed",detail:e.errors.map(r=>`${r.code}: ${r.detail}`).join("; ")}:(o.signals?.({ref:t.ref,verdict:"archived",reason:i.because}),{outcome:"retired"})}if(i.v==="approve"){let e=f({contextDir:o.contextDir,graph:n,verdicts:new Map([[p,{resolution:"approved"}]]),by:s});return e.errors?{outcome:"failed",detail:e.errors.map(r=>`${r.code}: ${r.detail}`).join("; ")}:(o.signals?.({ref:t.ref,verdict:"approved"}),{outcome:"applied"})}if(i.v==="merge"||i.v==="keep_both"){if(t.kind!=="PAIR"||!t.pair)return{outcome:"failed",detail:`${t.ref} is not a PAIR card`};let e=n.resolve(t.pair.candidate_cid);if(!e)return{outcome:"failed",detail:`pair candidate ${t.pair.candidate_ref} names nothing`};let r=n.tipOf(e.cid);if(i.v==="merge"){let d=k({contextDir:o.contextDir,graph:n,survivor:r,merged:p,reason:`pair merge: duplicate of ${t.pair.candidate_ref} (score ${t.pair.score})`,by:s});return d.errors?{outcome:"failed",detail:d.errors.map(c=>`${c.code}: ${c.detail}`).join("; ")}:(o.signals?.({ref:t.ref,verdict:"pair-merged",reason:t.pair.candidate_ref}),{outcome:"committed",detail:`merged into ${t.pair.candidate_ref} \u2014 survivor stays derived`})}let u=f({contextDir:o.contextDir,graph:n,verdicts:new Map([[p,{resolution:"approved"}],[r,{resolution:"approved"}]]),by:s});return u.errors?{outcome:"failed",detail:u.errors.map(d=>`${d.code}: ${d.detail}`).join("; ")}:(o.signals?.({ref:t.ref,verdict:"pair-kept-both",reason:t.pair.candidate_ref}),{outcome:"applied",detail:"both promoted as distinct"})}return{outcome:"failed",detail:`verdict ${i.v} does not apply to a ${t.kind} card`}}export{I as a,N as b,Y as c};
2
+ import{a as S}from"./chunk-I7TIGB7K.js";import{a as x,b as P,c as C,d as V,e as j}from"./chunk-DLJIML73.js";import{a as R,b as D}from"./chunk-DNNZ353O.js";import{C as y,c as b,r as f,s as k}from"./chunk-R4EGL7VM.js";import{e as w}from"./chunk-DBIBROYW.js";function I(o,t){return{contextDir:o,rootSid:t,locks:w(o,t),probe:S(o,{resolveAlias:i=>P(i),embed:(i,s)=>C(i,s),readVector:(i,s)=>V(o,i,s),writeVector:(i,s,n)=>j(o,i,s,n)})}}var N=new Set(["archive"]);async function Y(o,t,i,s){let n=y(o.contextDir);if(i.v==="defer")return{outcome:"deferred"};if(t.kind==="MODIFY_HELD"){if(!t.heldPayload)return{outcome:"failed",detail:`${t.ref} carries no held payload`};let e=t.heldPayload;if(i.v==="keep_current"){if(!e.event_id)return{outcome:"failed",detail:`this held row has no durable event id \u2014 resume the owner to drop it: kane-cli context extract --resume ${e.sid}`};let{commitChatTurn:r}=await import("./chat-committer-MAW25ICC.js"),u=r({contextDir:o.contextDir,graph:n,ops:[{kind:"resolve_question",questionId:`drop-held:${e.sid}:${e.tempRef}`,resolution:"deferred",eventId:e.event_id}],by:s});return u.errors?{outcome:"failed",detail:u.errors.map(d=>`${d.code}: ${d.detail}`).join("; ")}:(o.signals?.({ref:t.ref,verdict:"held-dropped"}),{outcome:"committed",detail:"held payload dropped (recorded) \u2014 the owner's resume will not re-present it"})}if(i.v==="approve"){let r=e.content._held??null;if(!r?.source_id||!r.source_cid||!r.anchor||!r.quote)return{outcome:"failed",detail:`this held row carries no committable provenance \u2014 resume the owner to apply it: kane-cli context extract --resume ${e.sid}`};{let a=n.mediaOf(r.source_cid),m=R(o.contextDir,n,r.source_cid),g=a.format==="image"?null:m?D(m):null;if(a.format!=="image"&&g===null)return{outcome:"failed",detail:`the pinned source ${r.source_id} (${r.source_cid.slice(0,19)}) has no citable text to verify this held row against \u2014 resume the owner: kane-cli context extract --resume ${e.sid}`};let _=b(a,{anchor:r.anchor,quote:r.quote},g);if(_.length>0)return{outcome:"failed",detail:`held provenance does not verify against the pinned source (${_.map($=>`${$.code}: ${$.detail}`).join("; ")}) \u2014 resume the owner: kane-cli context extract --resume ${e.sid}`}}let{commitProposal:u}=await import("./committer-42AFWMEX.js"),{_held:d,...c}=e.content,q={version:1,read_basis:n.latestHash,source:{source_id:r.source_id,source_cid:r.source_cid},use_cases:[{temp_ref:e.tempRef,title:String(c.title??e.tempRef),...c.summary!==void 0?{summary:c.summary}:{},risk:String(c.risk??"med"),cite:{anchor:r.anchor,quote:r.quote},depends_on_hint:[],matches_existing:null}]},l=await x(I(o.contextDir,o.rootSid??`review-${process.pid}`),{verb:"maintain",ucTargets:[],newBuCandidates:[{tempRef:e.tempRef,title:String(c.title??e.tempRef),probeText:`${String(c.title??"")} ${String(c.summary??"")}`.trim()}],sourcePins:[{source_id:r.source_id,source_cid:r.source_cid}],readBasis:n.latestHash,...e.event_id?{eventIds:[e.event_id]}:{}},a=>{let m=u({contextDir:o.contextDir,graph:a.graph,proposal:q,proposalId:null,verdicts:new Map([[e.tempRef,{resolution:"skipped"}]]),by:s,autoName:!0,allowStaleBasis:!0,eventIds:e.event_id?[e.event_id]:a.eventIds("maintain",1),sid:a.sid,probeHits:a.probeHits});return m.errors!==null?{errors:m.errors}:{result:m,record:m.record}}),h=l.ok&&"result"in l?l.result:{record:null,errors:l.ok?null:l.kind==="validation"?l.errors:[{code:l.kind==="contended"?l.err.code:"UNSETTLED",detail:l.kind==="contended"?`held by ${l.err.holder?.owner_sid??"another session"}`:"concurrent activity kept moving the store"}]};return h.errors?{outcome:"failed",detail:h.errors.map(a=>`${a.code}: ${a.detail}`).join("; ")}:(o.signals?.({ref:t.ref,verdict:"held-applied"}),{outcome:"committed",detail:`held payload committed (derived) by ${s.id}`})}return{outcome:"failed",detail:`verdict ${i.v} does not apply to a MODIFY_HELD card`}}let v=n.resolve(t.ref);if(!v)return{outcome:"failed",detail:`${t.ref} names nothing in the graph`};let p=n.tipOf(v.cid);if(i.v==="archive"){if(!i.because||!i.because.trim())return{outcome:"failed",detail:"archive requires --because (a reason the record keeps)"};let e=f({contextDir:o.contextDir,graph:n,verdicts:new Map([[p,{resolution:"rejected",reason:i.because}]]),by:s});return e.errors?{outcome:"failed",detail:e.errors.map(r=>`${r.code}: ${r.detail}`).join("; ")}:(o.signals?.({ref:t.ref,verdict:"archived",reason:i.because}),{outcome:"retired"})}if(i.v==="approve"){let e=f({contextDir:o.contextDir,graph:n,verdicts:new Map([[p,{resolution:"approved"}]]),by:s});return e.errors?{outcome:"failed",detail:e.errors.map(r=>`${r.code}: ${r.detail}`).join("; ")}:(o.signals?.({ref:t.ref,verdict:"approved"}),{outcome:"applied"})}if(i.v==="merge"||i.v==="keep_both"){if(t.kind!=="PAIR"||!t.pair)return{outcome:"failed",detail:`${t.ref} is not a PAIR card`};let e=n.resolve(t.pair.candidate_cid);if(!e)return{outcome:"failed",detail:`pair candidate ${t.pair.candidate_ref} names nothing`};let r=n.tipOf(e.cid);if(i.v==="merge"){let d=k({contextDir:o.contextDir,graph:n,survivor:r,merged:p,reason:`pair merge: duplicate of ${t.pair.candidate_ref} (score ${t.pair.score})`,by:s});return d.errors?{outcome:"failed",detail:d.errors.map(c=>`${c.code}: ${c.detail}`).join("; ")}:(o.signals?.({ref:t.ref,verdict:"pair-merged",reason:t.pair.candidate_ref}),{outcome:"committed",detail:`merged into ${t.pair.candidate_ref} \u2014 survivor stays derived`})}let u=f({contextDir:o.contextDir,graph:n,verdicts:new Map([[p,{resolution:"approved"}],[r,{resolution:"approved"}]]),by:s});return u.errors?{outcome:"failed",detail:u.errors.map(d=>`${d.code}: ${d.detail}`).join("; ")}:(o.signals?.({ref:t.ref,verdict:"pair-kept-both",reason:t.pair.candidate_ref}),{outcome:"applied",detail:"both promoted as distinct"})}return{outcome:"failed",detail:`verdict ${i.v} does not apply to a ${t.kind} card`}}export{I as a,N as b,Y as c};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as c}from"./chunk-FOP6CJAM.js";import{a as n}from"./chunk-RZ4F3BHX.js";import{u as s,v as a}from"./chunk-WEJA3EVI.js";import{createHash as h,randomBytes as g}from"crypto";var l=class{authBaseUrl;consentUrl;constructor(t="prod"){let e=c(t);this.authBaseUrl=e.authBaseUrl,this.consentUrl=e.consentUrl}static generatePkce(){let t=g(96).toString("base64url").slice(0,128),e=h("sha256").update(t).digest("base64url");return[t,e]}buildAuthorizationUrl(t,e,r,o){let i=new URLSearchParams({response_type:"code",client_id:t,redirect_uri:o,scope:a,code_challenge:e,code_challenge_method:"S256",state:r});return`${this.consentUrl}/oauth2?${i.toString()}`}async registerClient(t){let e=await n(`${this.authBaseUrl}/oauth2/register`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_name:s,redirect_uris:[t],grant_types:["authorization_code"],response_types:["code"],client_type:"public",application_type:"native"})});if(!e.ok)throw new Error(`DCR failed: ${e.status} ${await e.text()}`);return e.json()}async exchangeCode(t,e,r,o){let i=await n(`${this.authBaseUrl}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"authorization_code",code:t,redirect_uri:o,client_id:e,code_verifier:r})});if(!i.ok)throw new Error(`Token exchange failed: ${i.status}`);return i.json()}async refreshToken(t,e){let r=await n(`${this.authBaseUrl}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"refresh_token",refresh_token:t,client_id:e})});if(!r.ok)throw new Error(`Token refresh failed: ${r.status}`);return r.json()}async revokeToken(t,e,r="access_token"){await n(`${this.authBaseUrl}/oauth2/revoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:t,token_type_hint:r,client_id:e})})}async validateToken(t){let e=new AbortController,r=setTimeout(()=>e.abort(),1e4);try{let o=await n(`${this.authBaseUrl}/api/user`,{headers:{Authorization:`Bearer ${t}`,Accept:"application/json","Content-Type":"application/json"},signal:e.signal});return clearTimeout(r),o.ok}catch{return clearTimeout(r),!1}}};export{l as a};
2
+ import{a as c}from"./chunk-BE4FBVKY.js";import{a as n}from"./chunk-RZ4F3BHX.js";import{u as s,v as a}from"./chunk-DEUDRSU7.js";import{createHash as h,randomBytes as g}from"crypto";var l=class{authBaseUrl;consentUrl;constructor(t="prod"){let e=c(t);this.authBaseUrl=e.authBaseUrl,this.consentUrl=e.consentUrl}static generatePkce(){let t=g(96).toString("base64url").slice(0,128),e=h("sha256").update(t).digest("base64url");return[t,e]}buildAuthorizationUrl(t,e,r,o){let i=new URLSearchParams({response_type:"code",client_id:t,redirect_uri:o,scope:a,code_challenge:e,code_challenge_method:"S256",state:r});return`${this.consentUrl}/oauth2?${i.toString()}`}async registerClient(t){let e=await n(`${this.authBaseUrl}/oauth2/register`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_name:s,redirect_uris:[t],grant_types:["authorization_code"],response_types:["code"],client_type:"public",application_type:"native"})});if(!e.ok)throw new Error(`DCR failed: ${e.status} ${await e.text()}`);return e.json()}async exchangeCode(t,e,r,o){let i=await n(`${this.authBaseUrl}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"authorization_code",code:t,redirect_uri:o,client_id:e,code_verifier:r})});if(!i.ok)throw new Error(`Token exchange failed: ${i.status}`);return i.json()}async refreshToken(t,e){let r=await n(`${this.authBaseUrl}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"refresh_token",refresh_token:t,client_id:e})});if(!r.ok)throw new Error(`Token refresh failed: ${r.status}`);return r.json()}async revokeToken(t,e,r="access_token"){await n(`${this.authBaseUrl}/oauth2/revoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:t,token_type_hint:r,client_id:e})})}async validateToken(t){let e=new AbortController,r=setTimeout(()=>e.abort(),1e4);try{let o=await n(`${this.authBaseUrl}/api/user`,{headers:{Authorization:`Bearer ${t}`,Accept:"application/json","Content-Type":"application/json"},signal:e.signal});return clearTimeout(r),o.ok}catch{return clearTimeout(r),!1}}};export{l as a};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as Ot,b as Mt}from"./chunk-2UIHS2FH.js";import{a as vt}from"./chunk-BKHXPBWN.js";import{a as kt}from"./chunk-N2P4MI32.js";import{b as wt}from"./chunk-NVGBE2DR.js";import{a as Nt,b as Ft,c as St}from"./chunk-MSGW4JDG.js";import{c as G,e as Rt}from"./chunk-UR6MHSHU.js";var Lt=G(x=>{"use strict";Object.defineProperty(x,"__esModule",{value:!0});x.CHAR=`
2
+ import{a as vt}from"./chunk-BKHXPBWN.js";import{a as Ot,b as Mt}from"./chunk-2UIHS2FH.js";import{a as kt}from"./chunk-N2P4MI32.js";import{b as wt}from"./chunk-NVGBE2DR.js";import{a as Nt,b as Ft,c as St}from"./chunk-MSGW4JDG.js";import{c as G,e as Rt}from"./chunk-UR6MHSHU.js";var Lt=G(x=>{"use strict";Object.defineProperty(x,"__esModule",{value:!0});x.CHAR=`
3
3
  \r -\uD7FF\uE000-\uFFFD\u{10000}-\u{10FFFF}`;x.S=` \r
4
4
  `;x.NAME_START_CHAR=":A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}";x.NAME_CHAR="-"+x.NAME_START_CHAR+".0-9\xB7\u0300-\u036F\u203F-\u2040";x.CHAR_RE=new RegExp("^["+x.CHAR+"]$","u");x.S_RE=new RegExp("^["+x.S+"]+$","u");x.NAME_START_CHAR_RE=new RegExp("^["+x.NAME_START_CHAR+"]$","u");x.NAME_CHAR_RE=new RegExp("^["+x.NAME_CHAR+"]$","u");x.NAME_RE=new RegExp("^["+x.NAME_START_CHAR+"]["+x.NAME_CHAR+"]*$","u");x.NMTOKEN_RE=new RegExp("^["+x.NAME_CHAR+"]+$","u");var tt=9,et=10,st=13,it=32;x.S_LIST=[it,et,st,tt];function Ne(e){return e>=it&&e<=55295||e===et||e===st||e===tt||e>=57344&&e<=65533||e>=65536&&e<=1114111}x.isChar=Ne;function Fe(e){return e===it||e===et||e===st||e===tt}x.isS=Fe;function Pt(e){return e>=65&&e<=90||e>=97&&e<=122||e===58||e===95||e===8204||e===8205||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=767||e>=880&&e<=893||e>=895&&e<=8191||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}x.isNameStartChar=Pt;function Se(e){return Pt(e)||e>=48&&e<=57||e===45||e===46||e===183||e>=768&&e<=879||e>=8255&&e<=8256}x.isNameChar=Se});var Ht=G(f=>{"use strict";Object.defineProperty(f,"__esModule",{value:!0});f.CHAR="-\uD7FF\uE000-\uFFFD\u{10000}-\u{10FFFF}";f.RESTRICTED_CHAR="-\b\v\f-\x7F-\x84\x86-\x9F";f.S=` \r
5
5
  `;f.NAME_START_CHAR=":A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}";f.NAME_CHAR="-"+f.NAME_START_CHAR+".0-9\xB7\u0300-\u036F\u203F-\u2040";f.CHAR_RE=new RegExp("^["+f.CHAR+"]$","u");f.RESTRICTED_CHAR_RE=new RegExp("^["+f.RESTRICTED_CHAR+"]$","u");f.S_RE=new RegExp("^["+f.S+"]+$","u");f.NAME_START_CHAR_RE=new RegExp("^["+f.NAME_START_CHAR+"]$","u");f.NAME_CHAR_RE=new RegExp("^["+f.NAME_CHAR+"]$","u");f.NAME_RE=new RegExp("^["+f.NAME_START_CHAR+"]["+f.NAME_CHAR+"]*$","u");f.NMTOKEN_RE=new RegExp("^["+f.NAME_CHAR+"]+$","u");var yt=9,It=10,Bt=13,Xt=32;f.S_LIST=[Xt,It,Bt,yt];function we(e){return e>=1&&e<=55295||e>=57344&&e<=65533||e>=65536&&e<=1114111}f.isChar=we;function ke(e){return e>=1&&e<=8||e===11||e===12||e>=14&&e<=31||e>=127&&e<=132||e>=134&&e<=159}f.isRestrictedChar=ke;function ve(e){return e===9||e===10||e===13||e>31&&e<127||e===133||e>159&&e<=55295||e>=57344&&e<=65533||e>=65536&&e<=1114111}f.isCharAndNotRestricted=ve;function Oe(e){return e===Xt||e===It||e===Bt||e===yt}f.isS=Oe;function $t(e){return e>=65&&e<=90||e>=97&&e<=122||e===58||e===95||e===8204||e===8205||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=767||e>=880&&e<=893||e>=895&&e<=8191||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}f.isNameStartChar=$t;function Me(e){return $t(e)||e>=48&&e<=57||e===45||e===46||e===183||e>=768&&e<=879||e>=8255&&e<=8256}f.isNameChar=Me});var Ut=G(N=>{"use strict";Object.defineProperty(N,"__esModule",{value:!0});N.NC_NAME_START_CHAR="A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}";N.NC_NAME_CHAR="-"+N.NC_NAME_START_CHAR+".0-9\xB7\u0300-\u036F\u203F-\u2040";N.NC_NAME_START_CHAR_RE=new RegExp("^["+N.NC_NAME_START_CHAR+"]$","u");N.NC_NAME_CHAR_RE=new RegExp("^["+N.NC_NAME_CHAR+"]$","u");N.NC_NAME_RE=new RegExp("^["+N.NC_NAME_START_CHAR+"]["+N.NC_NAME_CHAR+"]*$","u");function Wt(e){return e>=65&&e<=90||e===95||e>=97&&e<=122||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=767||e>=880&&e<=893||e>=895&&e<=8191||e>=8204&&e<=8205||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}N.isNCNameStartChar=Wt;function Pe(e){return Wt(e)||e===45||e===46||e>=48&&e<=57||e===183||e>=768&&e<=879||e>=8255&&e<=8256}N.isNCNameChar=Pe});var Ct=G(B=>{"use strict";Object.defineProperty(B,"__esModule",{value:!0});B.SaxesParser=B.EVENTS=void 0;var X=Lt(),Le=Ht(),xt=Ut(),F=X.isS,ye=X.isChar,W=X.isNameStartChar,Vt=X.isNameChar,ne=X.S_LIST,Ie=X.NAME_RE,Be=Le.isChar,Xe=xt.isNCNameStartChar,$e=xt.isNCNameChar,He=xt.NC_NAME_RE,K="http://www.w3.org/XML/1998/namespace",I="http://www.w3.org/2000/xmlns/",We={__proto__:null,xml:K,xmlns:I},Ue={__proto__:null,amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},C=-1,k=-2,Gt=0,Ve=1,nt=2,Ge=3,P=4,qe=5,je=6,ze=7,rt=8,Ye=9,Qe=10,Ke=11,Ze=12,A=13,q=14,at=15,Je=16,ot=17,ts=18,es=19,ht=20,ss=21,is=22,ns=23,qt=24,lt=25,j=26,jt=27,rs=28,as=29,zt=30,os=31,hs=32,O=33,ls=34,ct=35,U=36,ut=37,cs=38,Yt=39,Qt=40,us=41,Kt=42,ds=43,fs=44,dt=9,w=10,ft=13,Zt=32,Jt=33,re=34,V=38,ae=39,z=45,Y=47,ps=59,v=60,L=61,D=62,T=63,oe=91,y=93,te=133,ee=8232,Q=e=>e===re||e===ae,he=[re,ae],ms=[...he,oe,D],gs=[...he,v,y],xs=[L,T,...ne],Cs=[...ne,D,V,v];function mt(e,t,s){switch(t){case"xml":s!==K&&e.fail(`xml prefix must be bound to ${K}.`);break;case"xmlns":s!==I&&e.fail(`xmlns prefix must be bound to ${I}.`);break;default:}switch(s){case I:e.fail(t===""?`the default namespace may not be set to ${s}.`:`may not assign a prefix (even "xmlns") to the URI ${I}.`);break;case K:switch(t){case"xml":break;case"":e.fail(`the default namespace may not be set to ${s}.`);break;default:e.fail("may not assign the xml namespace to another prefix.")}break;default:}}function _s(e,t){for(let s of Object.keys(t))mt(e,s,t[s])}var Es=e=>He.test(e),Ds=e=>Ie.test(e),M=0,se=1,pt=2;B.EVENTS=["xmldecl","text","processinginstruction","doctype","comment","opentagstart","attribute","opentag","closetag","cdata","error","end","ready"];var ie={xmldecl:"xmldeclHandler",text:"textHandler",processinginstruction:"piHandler",doctype:"doctypeHandler",comment:"commentHandler",opentagstart:"openTagStartHandler",attribute:"attributeHandler",opentag:"openTagHandler",closetag:"closeTagHandler",cdata:"cdataHandler",error:"errorHandler",end:"endHandler",ready:"readyHandler"},gt=class{constructor(t){this.opt=t??{},this.fragmentOpt=!!this.opt.fragment;let s=this.xmlnsOpt=!!this.opt.xmlns;if(this.trackPosition=this.opt.position!==!1,this.fileName=this.opt.fileName,s){this.nameStartCheck=Xe,this.nameCheck=$e,this.isName=Es,this.processAttribs=this.processAttribsNS,this.pushAttrib=this.pushAttribNS,this.ns=Object.assign({__proto__:null},We);let i=this.opt.additionalNamespaces;i!=null&&(_s(this,i),Object.assign(this.ns,i))}else this.nameStartCheck=W,this.nameCheck=Vt,this.isName=Ds,this.processAttribs=this.processAttribsPlain,this.pushAttrib=this.pushAttribPlain;this.stateTable=[this.sBegin,this.sBeginWhitespace,this.sDoctype,this.sDoctypeQuote,this.sDTD,this.sDTDQuoted,this.sDTDOpenWaka,this.sDTDOpenWakaBang,this.sDTDComment,this.sDTDCommentEnding,this.sDTDCommentEnded,this.sDTDPI,this.sDTDPIEnding,this.sText,this.sEntity,this.sOpenWaka,this.sOpenWakaBang,this.sComment,this.sCommentEnding,this.sCommentEnded,this.sCData,this.sCDataEnding,this.sCDataEnding2,this.sPIFirstChar,this.sPIRest,this.sPIBody,this.sPIEnding,this.sXMLDeclNameStart,this.sXMLDeclName,this.sXMLDeclEq,this.sXMLDeclValueStart,this.sXMLDeclValue,this.sXMLDeclSeparator,this.sXMLDeclEnding,this.sOpenTag,this.sOpenTagSlash,this.sAttrib,this.sAttribName,this.sAttribNameSawWhite,this.sAttribValue,this.sAttribValueQuoted,this.sAttribValueClosed,this.sAttribValueUnquoted,this.sCloseTag,this.sCloseTagSawWhite],this._init()}get closed(){return this._closed}_init(){var t;this.openWakaBang="",this.text="",this.name="",this.piTarget="",this.entity="",this.q=null,this.tags=[],this.tag=null,this.topNS=null,this.chunk="",this.chunkPosition=0,this.i=0,this.prevI=0,this.carriedFromPrevious=void 0,this.forbiddenState=M,this.attribList=[];let{fragmentOpt:s}=this;this.state=s?A:Gt,this.reportedTextBeforeRoot=this.reportedTextAfterRoot=this.closedRoot=this.sawRoot=s,this.xmlDeclPossible=!s,this.xmlDeclExpects=["version"],this.entityReturnState=void 0;let{defaultXMLVersion:i}=this.opt;if(i===void 0){if(this.opt.forceXMLVersion===!0)throw new Error("forceXMLVersion set but defaultXMLVersion is not set");i="1.0"}this.setXMLVersion(i),this.positionAtNewLine=0,this.doctype=!1,this._closed=!1,this.xmlDecl={version:void 0,encoding:void 0,standalone:void 0},this.line=1,this.column=0,this.ENTITIES=Object.create(Ue),(t=this.readyHandler)===null||t===void 0||t.call(this)}get position(){return this.chunkPosition+this.i}get columnIndex(){return this.position-this.positionAtNewLine}on(t,s){this[ie[t]]=s}off(t){this[ie[t]]=void 0}makeError(t){var s;let i=(s=this.fileName)!==null&&s!==void 0?s:"";return this.trackPosition&&(i.length>0&&(i+=":"),i+=`${this.line}:${this.column}`),i.length>0&&(i+=": "),new Error(i+t)}fail(t){let s=this.makeError(t),i=this.errorHandler;if(i===void 0)throw s;return i(s),this}write(t){if(this.closed)return this.fail("cannot write after close; assign an onready handler.");let s=!1;t===null?(s=!0,t=""):typeof t=="object"&&(t=t.toString()),this.carriedFromPrevious!==void 0&&(t=`${this.carriedFromPrevious}${t}`,this.carriedFromPrevious=void 0);let i=t.length,n=t.charCodeAt(i-1);!s&&(n===ft||n>=55296&&n<=56319)&&(this.carriedFromPrevious=t[i-1],i--,t=t.slice(0,i));let{stateTable:r}=this;for(this.chunk=t,this.i=0;this.i<i;)r[this.state].call(this);return this.chunkPosition+=i,s?this.end():this}close(){return this.write(null)}getCode10(){let{chunk:t,i:s}=this;if(this.prevI=s,this.i=s+1,s>=t.length)return C;let i=t.charCodeAt(s);if(this.column++,i<55296){if(i>=Zt||i===dt)return i;switch(i){case w:return this.line++,this.column=0,this.positionAtNewLine=this.position,w;case ft:return t.charCodeAt(s+1)===w&&(this.i=s+2),this.line++,this.column=0,this.positionAtNewLine=this.position,k;default:return this.fail("disallowed character."),i}}if(i>56319)return i>=57344&&i<=65533||this.fail("disallowed character."),i;let n=65536+(i-55296)*1024+(t.charCodeAt(s+1)-56320);return this.i=s+2,n>1114111&&this.fail("disallowed character."),n}getCode11(){let{chunk:t,i:s}=this;if(this.prevI=s,this.i=s+1,s>=t.length)return C;let i=t.charCodeAt(s);if(this.column++,i<55296){if(i>31&&i<127||i>159&&i!==ee||i===dt)return i;switch(i){case w:return this.line++,this.column=0,this.positionAtNewLine=this.position,w;case ft:{let r=t.charCodeAt(s+1);(r===w||r===te)&&(this.i=s+2)}case te:case ee:return this.line++,this.column=0,this.positionAtNewLine=this.position,k;default:return this.fail("disallowed character."),i}}if(i>56319)return i>=57344&&i<=65533||this.fail("disallowed character."),i;let n=65536+(i-55296)*1024+(t.charCodeAt(s+1)-56320);return this.i=s+2,n>1114111&&this.fail("disallowed character."),n}getCodeNorm(){let t=this.getCode();return t===k?w:t}unget(){this.i=this.prevI,this.column--}captureTo(t){let{i:s}=this,{chunk:i}=this;for(;;){let n=this.getCode(),r=n===k,a=r?w:n;if(a===C||t.includes(a))return this.text+=i.slice(s,this.prevI),a;r&&(this.text+=`${i.slice(s,this.prevI)}
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as Bt}from"./chunk-ZMNJBUAO.js";import{f as tr}from"./chunk-W5TTF7GB.js";import{a as Ft}from"./chunk-I7TIGB7K.js";import{a as te,c as Yt,e as Zt,f as qe,g as Qt,h as nr}from"./chunk-WXJQDLXX.js";import{a as Xt,b as rr,c as sr,d as ir,e as dt,f as or}from"./chunk-5G22NOZK.js";import{a as ke,b as qt,c as Gt,d as Lt,e as Vt}from"./chunk-C33E5XQM.js";import{a as zt}from"./chunk-L2TV4G56.js";import{a as Kt,b as Jt}from"./chunk-BZAGVBCX.js";import{c as Wt}from"./chunk-IVQX3AKL.js";import{e as Ut}from"./chunk-YHL5NA43.js";import{a as Fe}from"./chunk-NJQNHD5P.js";import{b as Nt}from"./chunk-YKTYVJBN.js";import{a as Ht,e as jt}from"./chunk-EV64VI66.js";import{a as er}from"./chunk-GX3FPJUG.js";import{g as Mt}from"./chunk-54JZ6VEW.js";import{a as $e,b as ct}from"./chunk-DNNZ353O.js";import{a as Se}from"./chunk-NVGBE2DR.js";import{b as nt}from"./chunk-IDX3TOPY.js";import{C as ee,m as be,q as Be}from"./chunk-W3Z7AZNT.js";import{g as It}from"./chunk-XMTSHHYQ.js";import{e as at}from"./chunk-DBIBROYW.js";import{d as me}from"./chunk-AKX4VRRR.js";import{b as Ot}from"./chunk-IAHKTEET.js";import{a as At}from"./chunk-5EOX4MEY.js";import{appendFileSync as wr,mkdirSync as ut,rmdirSync as br,writeFileSync as lt}from"fs";import{dirname as mr,extname as Sr,join as ce}from"path";var X=class extends Error{code;constructor(e,a){super(`${e}: ${a}`),this.name="ProposalAdapterError",this.code=e}};function cr(r){return r.version===2}var ar=8;function vr(r){let e=/^extract@(\d+)$/.exec(r??"");return e?Number.parseInt(e[1],10):null}var yr=r=>typeof r=="object"&&r!==null&&"op"in r;function Ge(r,e,a){return{anchor:r.anchor,quote:r.quote,...a||r.source_id!==e?{source_id:r.source_id}:{}}}function dr(r,e,a={}){let m=vr(a.templateVersion),x=m!==null&&m>=5,_=m!==null&&m<5,y=r.archived!=null&&r.archived.length>0&&m!==null&&m<5;if(y&&a.warn?.(`dropped ${r.archived.length} archive op(s): the bound extract template @${m} never described archiving \u2014 nothing was archived; the use-cases still land`),!x&&r.read_basis.length!==1)throw new X("READ_BASIS_COUNT",`read_basis must have exactly 1 element, got ${r.read_basis.length}`);if(r.read_basis.length===0)throw new X("READ_BASIS_COUNT","read_basis must not be empty");let v=r.read_basis[0],h=r.read_basis.length>1,$=r.use_cases.map(i=>{if(_&&i.cite.length!==1)throw new X("CITE_COUNT",`${i.temp_ref}: cite must have exactly 1 element, got ${i.cite.length}`);if(i.cite.length<1||i.cite.length>ar)throw new X("CITE_COUNT",`${i.temp_ref}: 1..${ar} cites allowed, got ${i.cite.length}`);let M=(f,re)=>{if(!x&&f!==v.source_id)throw new X("SOURCE_MISMATCH",`${re}: cite source ${f} != read_basis source ${v.source_id} (single-source)`)};M(i.cite[0].source_id,i.temp_ref);let P=i.cite.map(f=>(M(f.source_id,i.temp_ref),Ge(f,v.source_id,x&&(h||f.source_id!==v.source_id)))),l=(i.updated?.criteria??[]).some(yr);if(!x&&l)throw new X("CRITERIA_OPS_UNSUPPORTED",`${i.temp_ref}: op-union updated.criteria (keep/set/remove) needs an extract@5+ binding \u2014 this session is bound to ${a.templateVersion??"an unversioned template"}`);return{temp_ref:i.temp_ref,title:i.title,...i.description!==void 0?{description:i.description}:{},...i.summary!==void 0?{summary:i.summary}:{},...i.actors!==void 0?{actors:i.actors}:{},...i.value!==void 0?{value:i.value}:{},risk:i.risk,cite:P[0],...P.length>1?{cites:P}:{},...i.criteria!=null&&i.criteria.length>0?{criteria:i.criteria.map((f,re)=>(M(f.cite.source_id,`${i.temp_ref}.criteria[${re}]`),{text:f.text,cite:Ge(f.cite,v.source_id,x&&f.cite.source_id!==v.source_id)}))}:{},depends_on_hint:i.depends_on_hint,matches_existing:i.matches_existing,...i.conflicts_with!=null?{conflicts_with:i.conflicts_with}:{},...i.changed?{changed:!0}:{},...i.updated!=null?{updated:{...i.updated.title!=null?{title:i.updated.title}:{},...i.updated.description!=null?{description:i.updated.description}:{},...i.updated.summary!=null?{summary:i.updated.summary}:{},...i.updated.actors!=null?{actors:i.updated.actors}:{},...i.updated.value!=null?{value:i.updated.value}:{},...i.updated.risk!=null?{risk:i.updated.risk}:{},...i.updated.criteria!=null?{criteria:l?i.updated.criteria.map(f=>f.op==="set"?{op:"set",text:f.text,cite:Ge(f.cite,v.source_id,x&&f.cite.source_id!==v.source_id)}:f.op==="keep"?{op:"keep",ref:f.ref,text:f.text}:{op:"remove",ref:f.ref,text:f.text,reason:f.reason}):i.updated.criteria.map((f,re)=>(M(f.cite.source_id,`${i.temp_ref}.updated.criteria[${re}]`),{text:f.text,cite:Ge(f.cite,v.source_id,x&&f.cite.source_id!==v.source_id)}))}:{}}}:{},...i.change_note!=null?{change_note:i.change_note}:{}}});return{version:1,read_basis:e,source:{source_id:v.source_id,source_cid:v.source_cid},use_cases:$,...h?{sources:r.read_basis.map(i=>({source_id:i.source_id,source_cid:i.source_cid}))}:{},...r.extraction_of!=null&&r.extraction_of.length>0?{extraction_claims:r.extraction_of.map(i=>({source_id:i.source_id,completeness:i.completeness}))}:{},...r.archived!=null&&r.archived.length>0&&!y?{archived:r.archived.map(i=>({target:i.target,reason:i.reason,basis:i.basis}))}:{}}}function ur(r){let{contextDir:e,graph:a}=r,m=r.maxDigestBytes??4096,x={},_=[];for(let[h,$]of a.heads){if(x[h]=$,typeof $!="string")continue;let i=a.mediaOf($),M=a.getNode($)?.content?.blob;if(typeof M=="string")if(i.format==="image")_.push({source_id:h,cid:$,format:"image",blobRef:{path:Se(e,M),cid:M}});else{let P=$e(e,a,$)?.toString("utf8")??"";_.push({source_id:h,cid:$,format:i.format,text:P})}}_.sort((h,$)=>h.source_id<$.source_id?-1:1);let y=[];for(let h of a.byLabel(me.STYLENOTE).sort(($,i)=>$.cid<i.cid?-1:1))a.superseded.has(h.cid)||y.push(`\u2022 ${String(h.content.statement)} [${String(h.content.learned_from_kind)}]`);let v="";for(let h of y){if(Buffer.byteLength(v+h+`
2
+ import{b as Bt}from"./chunk-ZMNJBUAO.js";import{f as tr}from"./chunk-W5TTF7GB.js";import{a as te,c as Yt,e as Zt,f as qe,g as Qt,h as nr}from"./chunk-NLSR2IFN.js";import{a as Xt,b as rr,c as sr,d as ir,e as dt,f as or}from"./chunk-QHSF2CXK.js";import{a as Kt,b as Jt}from"./chunk-BZAGVBCX.js";import{a as Ft}from"./chunk-I7TIGB7K.js";import{a as ke,b as qt,c as Gt,d as Lt,e as Vt}from"./chunk-DLJIML73.js";import{a as zt}from"./chunk-L2TV4G56.js";import{c as Wt}from"./chunk-B7K5WOOU.js";import{e as Ut}from"./chunk-G5ZGEZCA.js";import{a as Fe}from"./chunk-7HUJVIMO.js";import{b as Nt}from"./chunk-YKTYVJBN.js";import{a as Ht,e as jt}from"./chunk-DP7GPS6S.js";import{a as er}from"./chunk-GX3FPJUG.js";import{g as Mt}from"./chunk-3D7VYEDP.js";import{a as $e,b as ct}from"./chunk-DNNZ353O.js";import{a as Se}from"./chunk-NVGBE2DR.js";import{b as nt}from"./chunk-IDX3TOPY.js";import{C as ee,m as be,q as Be}from"./chunk-R4EGL7VM.js";import{g as It}from"./chunk-OXHMUZJV.js";import{e as at}from"./chunk-DBIBROYW.js";import{b as Ot}from"./chunk-IAHKTEET.js";import{d as me}from"./chunk-AKX4VRRR.js";import{a as At}from"./chunk-5EOX4MEY.js";import{appendFileSync as wr,mkdirSync as ut,rmdirSync as br,writeFileSync as lt}from"fs";import{dirname as mr,extname as Sr,join as ce}from"path";var X=class extends Error{code;constructor(e,a){super(`${e}: ${a}`),this.name="ProposalAdapterError",this.code=e}};function cr(r){return r.version===2}var ar=8;function vr(r){let e=/^extract@(\d+)$/.exec(r??"");return e?Number.parseInt(e[1],10):null}var yr=r=>typeof r=="object"&&r!==null&&"op"in r;function Ge(r,e,a){return{anchor:r.anchor,quote:r.quote,...a||r.source_id!==e?{source_id:r.source_id}:{}}}function dr(r,e,a={}){let m=vr(a.templateVersion),x=m!==null&&m>=5,_=m!==null&&m<5,y=r.archived!=null&&r.archived.length>0&&m!==null&&m<5;if(y&&a.warn?.(`dropped ${r.archived.length} archive op(s): the bound extract template @${m} never described archiving \u2014 nothing was archived; the use-cases still land`),!x&&r.read_basis.length!==1)throw new X("READ_BASIS_COUNT",`read_basis must have exactly 1 element, got ${r.read_basis.length}`);if(r.read_basis.length===0)throw new X("READ_BASIS_COUNT","read_basis must not be empty");let v=r.read_basis[0],h=r.read_basis.length>1,$=r.use_cases.map(i=>{if(_&&i.cite.length!==1)throw new X("CITE_COUNT",`${i.temp_ref}: cite must have exactly 1 element, got ${i.cite.length}`);if(i.cite.length<1||i.cite.length>ar)throw new X("CITE_COUNT",`${i.temp_ref}: 1..${ar} cites allowed, got ${i.cite.length}`);let M=(f,re)=>{if(!x&&f!==v.source_id)throw new X("SOURCE_MISMATCH",`${re}: cite source ${f} != read_basis source ${v.source_id} (single-source)`)};M(i.cite[0].source_id,i.temp_ref);let P=i.cite.map(f=>(M(f.source_id,i.temp_ref),Ge(f,v.source_id,x&&(h||f.source_id!==v.source_id)))),l=(i.updated?.criteria??[]).some(yr);if(!x&&l)throw new X("CRITERIA_OPS_UNSUPPORTED",`${i.temp_ref}: op-union updated.criteria (keep/set/remove) needs an extract@5+ binding \u2014 this session is bound to ${a.templateVersion??"an unversioned template"}`);return{temp_ref:i.temp_ref,title:i.title,...i.description!==void 0?{description:i.description}:{},...i.summary!==void 0?{summary:i.summary}:{},...i.actors!==void 0?{actors:i.actors}:{},...i.value!==void 0?{value:i.value}:{},risk:i.risk,cite:P[0],...P.length>1?{cites:P}:{},...i.criteria!=null&&i.criteria.length>0?{criteria:i.criteria.map((f,re)=>(M(f.cite.source_id,`${i.temp_ref}.criteria[${re}]`),{text:f.text,cite:Ge(f.cite,v.source_id,x&&f.cite.source_id!==v.source_id)}))}:{},depends_on_hint:i.depends_on_hint,matches_existing:i.matches_existing,...i.conflicts_with!=null?{conflicts_with:i.conflicts_with}:{},...i.changed?{changed:!0}:{},...i.updated!=null?{updated:{...i.updated.title!=null?{title:i.updated.title}:{},...i.updated.description!=null?{description:i.updated.description}:{},...i.updated.summary!=null?{summary:i.updated.summary}:{},...i.updated.actors!=null?{actors:i.updated.actors}:{},...i.updated.value!=null?{value:i.updated.value}:{},...i.updated.risk!=null?{risk:i.updated.risk}:{},...i.updated.criteria!=null?{criteria:l?i.updated.criteria.map(f=>f.op==="set"?{op:"set",text:f.text,cite:Ge(f.cite,v.source_id,x&&f.cite.source_id!==v.source_id)}:f.op==="keep"?{op:"keep",ref:f.ref,text:f.text}:{op:"remove",ref:f.ref,text:f.text,reason:f.reason}):i.updated.criteria.map((f,re)=>(M(f.cite.source_id,`${i.temp_ref}.updated.criteria[${re}]`),{text:f.text,cite:Ge(f.cite,v.source_id,x&&f.cite.source_id!==v.source_id)}))}:{}}}:{},...i.change_note!=null?{change_note:i.change_note}:{}}});return{version:1,read_basis:e,source:{source_id:v.source_id,source_cid:v.source_cid},use_cases:$,...h?{sources:r.read_basis.map(i=>({source_id:i.source_id,source_cid:i.source_cid}))}:{},...r.extraction_of!=null&&r.extraction_of.length>0?{extraction_claims:r.extraction_of.map(i=>({source_id:i.source_id,completeness:i.completeness}))}:{},...r.archived!=null&&r.archived.length>0&&!y?{archived:r.archived.map(i=>({target:i.target,reason:i.reason,basis:i.basis}))}:{}}}function ur(r){let{contextDir:e,graph:a}=r,m=r.maxDigestBytes??4096,x={},_=[];for(let[h,$]of a.heads){if(x[h]=$,typeof $!="string")continue;let i=a.mediaOf($),M=a.getNode($)?.content?.blob;if(typeof M=="string")if(i.format==="image")_.push({source_id:h,cid:$,format:"image",blobRef:{path:Se(e,M),cid:M}});else{let P=$e(e,a,$)?.toString("utf8")??"";_.push({source_id:h,cid:$,format:i.format,text:P})}}_.sort((h,$)=>h.source_id<$.source_id?-1:1);let y=[];for(let h of a.byLabel(me.STYLENOTE).sort(($,i)=>$.cid<i.cid?-1:1))a.superseded.has(h.cid)||y.push(`\u2022 ${String(h.content.statement)} [${String(h.content.learned_from_kind)}]`);let v="";for(let h of y){if(Buffer.byteLength(v+h+`
3
3
  `,"utf8")>m)break;v+=h+`
4
4
  `}return{read_basis:x,sources:_,styleNoteDigest:v}}function lr(r,e){let a=ur({contextDir:r,graph:e}).styleNoteDigest;return a.length>0?a:void 0}function mt(r,e,a,m,x){let _=null,y=()=>_??=x&&Object.keys(x).length>0?Promise.resolve(x):Ut().catch(()=>({}));return{contextDir:r,rootSid:e,locks:at(r,e),probe:m??Ft(r,{resolveAlias:async v=>qt(v,{env:process.env,auth:await y()}),embed:async(v,h)=>Gt(v,h,{env:process.env,auth:await y()}),readVector:(v,h)=>Lt(r,v,h),writeVector:(v,h,$)=>Vt(r,v,h,$)}),...a?.length?{reservedEventIds:a}:{}}}function ht(r,e){let a=[],m=[];for(let x of r.use_cases){let _=x.matches_existing;_?.cid&&e.hasNode(_.cid)?a.push({ref:_.cid,expectedTip:e.tipOf(_.cid)}):m.push({tempRef:x.temp_ref,title:String(x.title??""),probeText:String(x.title??"")})}return{verb:"extract",ucTargets:a,newBuCandidates:m,sourcePins:[{source_id:r.source.source_id,source_cid:r.source.source_cid}],readBasis:r.read_basis??null}}function $r(r,e){let a=(r.images??[]).filter(m=>m.delivery==="selected");if(a.length!==0)return a.map(m=>({ref:m.ref,...m.page!==void 0?{page:m.page}:{},...m.loc!==void 0?{loc:m.loc}:{},media_type:m.media_type,blob_ref:{path:Se(e,m.blob),cid:m.blob}}))}function kr(r){return r.length>8&&r[0]===137&&r[1]===80&&r[2]===78&&r[3]===71?"image/png":r.length>3&&r[0]===255&&r[1]===216&&r[2]===255?"image/jpeg":r.length>12&&r.toString("ascii",0,4)==="RIFF"&&r.toString("ascii",8,12)==="WEBP"?"image/webp":null}function Le(r){return r.toISOString().replace(/[-:]/g,"").slice(0,15)}function hr(r){return r.startsWith("su-conv-")?`conv-${Ot(Buffer.from(r,"utf8")).slice(0,8)}`:r}function pr(r){return r.source_id.startsWith("su-conv-")?"the conversation":r.source_id}function Rr(r,e,a){return`reading ${pr(r)}${a>1?` (source ${e} of ${a})`:""}`}function Re(r){return r.toLowerCase().trim().replace(/\s+/g," ")}function gr(r,e){let a=new Map,m=new Map,x=new Map;for(let{cid:y,content:v}of e.byLabel(me.USECASE)){if(e.superseded.has(y))continue;(e.trust.get(y)==="archived"?x:m).set(Re(String(v.title??"")),y)}let _=y=>e.trust.get(y)==="archived"?{cid:y,archived:!0,reason:e.archivedReason.get(y)}:{cid:y};for(let y of r.use_cases){if(y.matches_existing){let $=y.matches_existing.cid;if(e.superseded.has($)){let i=e.tipOf($);$=e.superseded.has(i)?null:i}if($!==null){a.set(y.temp_ref,_($));continue}}let v=m.get(Re(y.title));if(v){a.set(y.temp_ref,{cid:v});continue}let h=x.get(Re(y.title));h&&a.set(y.temp_ref,_(h))}return a}var fr=/^(\S+)\.criteria\[(\d+)\]/;function Cr(r,e,a){if(e.length===0||!e.every(x=>fr.test(x.detail)))return!1;let m=new Map;for(let x of e){let _=fr.exec(x.detail),y=m.get(_[1])??new Set;y.add(Number(_[2])),m.set(_[1],y)}for(let x of r.use_cases){let _=m.get(x.temp_ref);_?.size&&(x.criteria=(x.criteria??[]).filter((y,v)=>!_.has(v)),a(`${x.temp_ref}: dropped ${_.size} criteria with unverifiable cites \u2014 committed without them (criteria are hints, not oracles)`))}return!0}async function gt(r,e,a,m,x=()=>{},_,y){let v=(h,$)=>x(h,$,r.session_id);return Zt(r,e,a,m,x,{async onProposalEvent(h){let $=h,i=null,M=null;if(cr($))try{i=dr($,r.read_basis,{templateVersion:y?.()??null,warn:P=>{e.out(`warning: ${P}`),v("adapter",{warn:P})}}),v("adapter",{ok:!0,use_cases:i.use_cases.length})}catch(P){M=P instanceof X?P.message:String(P),v("adapter",{ok:!1,error:M})}else i=$;return i&&i.use_cases.length===0&&(e.out("warning: the agent proposed ZERO use-cases for this source"),e.emit?.({type:"warning",code:"ZERO_USE_CASES",message:"the agent proposed ZERO use-cases for this source"})),i&&_&&await _(i),{proposal:i,error:M}}})}var Dr=new Set(["agent","ci","override"]);async function Ss(r,e){let a=`ext-${Le(e.now?.()??new Date)}-lk${Math.random().toString(36).slice(2,8)}`,x=at(e.contextDir,a,e.now?{now:e.now}:void 0).tryAcquire([{kind:"extract"}],{hold:"session",verb:"extract"});if("contended"in x){let _=x.contended.holder,y=`another extraction is running on this context${_?` (pid ${_.pid})`:""} \u2014 retry when it finishes`;return e.out(y),e.emit?.({type:"error",message:y,code:"EXTRACT_LOCKED"}),2}try{return await Er(r,e)}finally{x.release()}}async function Er(r,e){let a=r.mode??"interactive";if(r.posture==="reconcile"){if(r.trust==="hold"){let o="error: --trust hold has no meaning here \u2014 a reconcile IS the review; drop the flag";return e.out(`${o} [TRUST_USAGE]`),e.emit?.({type:"error",message:o,code:"TRUST_USAGE"}),2}if(!r.source||!r.changeContext){let o="reconcile posture needs a pinned source and its change context \u2014 internal wiring fault";return e.out(`error: ${o}`),e.emit?.({type:"error",message:o,code:"POSTURE_USAGE"}),2}if(a==="ci"){let o="reconcile posture is not available under --mode ci \u2014 a held changeset needs a durable session; use --mode agent";return e.out(`error: ${o}`),e.emit?.({type:"error",message:o,code:"POSTURE_USAGE"}),2}}if(r.trust==="hold"&&a==="interactive")return e.out("error: --trust hold only applies to headless runs \u2014 in interactive chat you review items in-session anyway; use --mode agent to hold everything for review"),e.emit?.({type:"error",message:"error: --trust hold only applies to headless runs \u2014 use --mode agent",code:"TRUST_USAGE"}),2;if(a==="interactive"){if(!e.isTTY)return e.out("extract: --mode interactive needs a TTY (use --mode agent|ci|override headless)"),2}else if(!Dr.has(a))return e.out(`extract: unknown mode "${a}" \u2014 interactive | agent | ci | override`),2;if(r.trust!==void 0){if(a==="ci")return e.out("error: --trust is not available under --mode ci (ci is fail-closed \u2014 no trust dials)"),e.emit?.({type:"error",message:"error: --trust is not available under --mode ci",code:"TRUST_UNDER_CI"}),2;if(r.trust!=="auto"&&r.trust!=="hold")return e.out(`error: --trust must be auto | hold, got '${r.trust}'`),e.emit?.({type:"error",message:`error: --trust must be auto | hold, got '${r.trust}'`,code:"TRUST_USAGE"}),2}let m=e.telemetry?.enabled?e.telemetry:void 0,x=Le(e.now?.()??new Date),_=m?At(m.ids.context_instance_id??null,"extract",m.ids.session_id):ce(e.contextDir,"logs",`extract-${x}.log`);ut(mr(_),{recursive:!0});let y=`run-${x}-${Math.random().toString(36).slice(2,8)}`,v=o=>o==="error"||o==="failed_proposal"?"error":o==="repair_respawn"?"warn":"info",h=(o,u,s)=>{try{wr(_,JSON.stringify({ts:new Date().toISOString(),level:v(o),run_id:y,...m?{user_session_id:m.ids.session_id}:{},...s?{session_id:s}:{},kind:o,data:u})+`
5
5
  `)}catch{}m?.wireTrace(o,u,s)};{let o=e.out;e.out=u=>{h("transcript",{line:u}),o(u)}}e.chat||e.out(`trace: ${te(_)}`),e.emit?.({type:"run_start",mode:a,trace:_,...m?{session:m.ids.session_id}:{}});let $=Nt();if($&&e.out($),e.preflightTurn){let o=await e.preflightTurn();if(h("preflight",o),!o.ok)return e.out(o.message??"error: turn-endpoint preflight failed"),e.emit?.({type:"error",message:o.message??"error: turn-endpoint preflight failed",code:"PREFLIGHT"}),2}let i=ee(e.contextDir),M=lr(e.contextDir,i),P=r.sources?.length?r.sources:r.source?[r.source]:[];if(P.length>0){if(r.resume){let o="error: --source cannot be combined with --resume (the resumed session already has its scope)";return e.out(o),e.emit?.({type:"error",message:o,code:"SOURCE_WITH_RESUME"}),2}for(let o of P){let u=i.heads.get(o);if(typeof u!="string"){let s=u===null?`error: --source ${o} was ingested but is retired \u2014 re-ingest it to extract again`:`error: --source ${o} is not an ingested source (kane-cli context list shows them)`;return e.out(s),e.emit?.({type:"error",message:s,code:"SOURCE_UNKNOWN"}),2}}}let l=null,f=null;if(r.resume){try{{let c=await or(e.contextDir,r.resume,i,{verb:"extract",deps:{onWarn:C=>e.out(`note: ${C}`)}});{let C=Object.keys(c.handle.state.read_basis??{});if(C.length>1){let B=`error: session ${r.resume} spans ${C.length} sources \u2014 multi-source resume isn't supported yet; committed work is preserved (re-run kane-cli context extract for anything remaining)`;return e.out(B),e.emit?.({type:"error",message:B,code:"MULTI_SOURCE_RESUME"}),c.handle.release(),2}f=c,h("resume_kind",{kind:c.view.pointer===null?"bare-base":c.view.pointer.at==="final"?"pause":"crash"}),l={handle:c.handle,represent:c.represent,questions:c.questions,staleBasis:c.drift.map(B=>B.subject)}}}}catch(c){let C=c instanceof Error?c.message:String(c);return e.out(`error: ${C}`),e.emit?.({type:"error",message:`error: ${C}`,...c instanceof dt?{code:c.code}:{}}),c instanceof dt?2:1}let o=f?null:Xt(l.handle.state.verb,"extract",r.resume);if(o)return e.out(o.message),e.emit?.({type:"error",message:o.message,code:o.code}),l.handle.release(),2;let u=l.handle.state.change_basis;if(u&&(i.heads.get(u.source_id)??null)!==u.new_head){let c=`error: ${u.source_id} moved while this reconcile extraction was paused \u2014 its recorded change context no longer matches; re-run kane-cli maintain reconcile against the current file (session ${r.resume} is defunct and can be ignored)`;return e.out(c),e.emit?.({type:"error",message:c,code:"CHANGE_BASIS_MOVED"}),l.handle.release(),2}if(f&&f.view.pointer!==null&&f.drift.length>0){if(!await e.confirmStale(`changed since the pause: ${f.drift.map(C=>C.subject).join(", ")} \u2014 re-ground and continue against the current versions?`)){let C=`resume aborted: the context moved since the pause (${f.drift.map(B=>B.subject).join(", ")}) \u2014 session ${r.resume} is preserved`;return e.out(C),e.emit?.({type:"error",message:C,code:"RESUME_DRIFT"}),l.handle.release(),2}}else l.staleBasis.length>0&&e.out(`note: changed since the pause: ${l.staleBasis.join(", ")} \u2014 re-presented items may be stale`);let s=[...new Set([...l.handle.state.held_receipts??[],...f?.view.kane?.held_receipts??[]])];if(s.length>0)if(e.chat?.holdReceipt)for(let c of s)e.chat.holdReceipt(c);else e={...e,initialMessage:[s.join(`