@testmuai/kane-cli 0.10.3 → 0.10.5

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 (425) hide show
  1. package/dist/ChatSurface-WKYH5MYP.js +2 -0
  2. package/dist/ChromeProfilePicker-ROQIRMWR.js +2 -0
  3. package/dist/{CliFeedbackPrompt-JWCTMIGI.js → CliFeedbackPrompt-55OKAT4W.js} +1 -1
  4. package/dist/{CliUploadProgress-XFRRFRL4.js → CliUploadProgress-NK2U3CKQ.js} +1 -1
  5. package/dist/{ConfigView-6JF4DOJN.js → ConfigView-7A5JTKLF.js} +1 -1
  6. package/dist/EvidenceViewOffer-U7J5ZRVK.js +2 -0
  7. package/dist/FolderPicker-R4QDIFTW.js +2 -0
  8. package/dist/InfoBox-SRQ4TSUT.js +2 -0
  9. package/dist/LinksBox-7BWLLQVR.js +2 -0
  10. package/dist/ProfilesView-TQTJR4WQ.js +2 -0
  11. package/dist/ProjectPicker-A5SXNDUL.js +2 -0
  12. package/dist/SaveSessionPrompt-IECYZMXW.js +2 -0
  13. package/dist/SingleShotApp-MN5IE6EU.js +2 -0
  14. package/dist/SummaryBox-WFOS6GON.js +2 -0
  15. package/dist/TestMdRunView-URNSXIVC.js +2 -0
  16. package/dist/TestrunEvidenceTable-SZPZMW3J.js +2 -0
  17. package/dist/{WhoamiView-H7JNLLCY.js → WhoamiView-G6QP4SID.js} +1 -1
  18. package/dist/{app-client-U2YYF65L.js → app-client-2RR5ATI6.js} +1 -1
  19. package/dist/app-download-UGLDWWTX.js +2 -0
  20. package/dist/{assurance-job-F4L3T4VJ.js → assurance-job-V5QB36WJ.js} +1 -1
  21. package/dist/{binary-K3XMILST.js → binary-32FXH6PQ.js} +1 -1
  22. package/dist/bind-3PB77PWJ.js +2 -0
  23. package/dist/bootstrap-A2O4UZUJ.js +2 -0
  24. package/dist/{bridge-2UHJOVLX.js → bridge-SPGIYAAG.js} +1 -1
  25. package/dist/{catalog-YCU6OHNV.js → catalog-P5IOIVYP.js} +1 -1
  26. package/dist/{catalog-client-MVEEHTG2.js → catalog-client-LR2KPSU7.js} +1 -1
  27. package/dist/{changelog-5UB3AQT6.js → changelog-GKIKDJ32.js} +1 -1
  28. package/dist/chat-committer-7E3TRZ6P.js +2 -0
  29. package/dist/chat-controller-5ZBG23L6.js +2 -0
  30. package/dist/child-MNLSG77W.js +2 -0
  31. package/dist/{chunk-5YYCCM6K.js → chunk-2AHQ3D3D.js} +1 -1
  32. package/dist/{chunk-UWPG5MWM.js → chunk-2EKLTUY2.js} +1 -1
  33. package/dist/{chunk-KL7XFNSD.js → chunk-2G7UYQOW.js} +1 -1
  34. package/dist/{chunk-GXQYFOBD.js → chunk-2MBNAW2G.js} +1 -1
  35. package/dist/{chunk-Y2HQMJGS.js → chunk-2NP3THOE.js} +1 -1
  36. package/dist/chunk-37KFCYHG.js +18 -0
  37. package/dist/{chunk-ZHAMVLQZ.js → chunk-3A4KK22B.js} +1 -1
  38. package/dist/{chunk-L3BUPFAQ.js → chunk-3CFAE36M.js} +1 -1
  39. package/dist/{chunk-TU2KPOW2.js → chunk-3DFBFYTD.js} +2 -2
  40. package/dist/{chunk-QE4AWNOV.js → chunk-3RJRCAUX.js} +6 -6
  41. package/dist/chunk-3UY4WPMQ.js +8 -0
  42. package/dist/{chunk-3NWUXRSI.js → chunk-4DM5EWEV.js} +1 -1
  43. package/dist/{chunk-ZMWTRXFH.js → chunk-4DRFMDAW.js} +1 -1
  44. package/dist/{chunk-PI7OXS62.js → chunk-5EAJO372.js} +1 -1
  45. package/dist/{chunk-4KL3TSTT.js → chunk-5K7PCSTP.js} +4 -4
  46. package/dist/{chunk-HV2CDY4K.js → chunk-5LKDOE3P.js} +1 -1
  47. package/dist/{chunk-AT7AT3AR.js → chunk-5OFHMBZC.js} +5 -5
  48. package/dist/{chunk-CQDCNP7V.js → chunk-5ORBAYTU.js} +1 -1
  49. package/dist/{chunk-2TK4MDF2.js → chunk-63BFLTJI.js} +1 -1
  50. package/dist/{chunk-BBJAKSA7.js → chunk-642GD7E6.js} +2 -2
  51. package/dist/{chunk-KKLCXRW6.js → chunk-642LB5R2.js} +1 -1
  52. package/dist/{chunk-Q4SMITTV.js → chunk-66C5A2F5.js} +1 -1
  53. package/dist/{chunk-X6FCXBXU.js → chunk-6FVGPKVX.js} +1 -1
  54. package/dist/{chunk-32HED7X2.js → chunk-6KUUSONE.js} +1 -1
  55. package/dist/{chunk-6FFX4S7N.js → chunk-6OL5EVRC.js} +1 -1
  56. package/dist/{chunk-SXBPUUQ5.js → chunk-6PZ3SVWE.js} +1 -1
  57. package/dist/{chunk-SJQTTEXQ.js → chunk-6VG2FG67.js} +1 -1
  58. package/dist/chunk-6WN4WSXR.js +2 -0
  59. package/dist/{chunk-CB2BWDHG.js → chunk-76MKY7FG.js} +4 -4
  60. package/dist/{chunk-LRNUGKYH.js → chunk-77BZTEHJ.js} +1 -1
  61. package/dist/chunk-7TSM2FCL.js +5 -0
  62. package/dist/{chunk-KQ4XKTIZ.js → chunk-A5C7HIAH.js} +1 -1
  63. package/dist/{chunk-ENRFXGID.js → chunk-ABAUIIPD.js} +1 -1
  64. package/dist/{chunk-JTNEF5ZP.js → chunk-AL6IAMYV.js} +1 -1
  65. package/dist/{chunk-4CJQ7XZP.js → chunk-AXOSLGQ4.js} +1 -1
  66. package/dist/{chunk-CNHKZE4F.js → chunk-BDZWRJAL.js} +1 -1
  67. package/dist/{chunk-VCVEZEVS.js → chunk-BFRWZPIK.js} +1 -1
  68. package/dist/{chunk-IZ66FKPC.js → chunk-BIGOLVK6.js} +1 -1
  69. package/dist/{chunk-Q4ALB7SH.js → chunk-BLHFNL5K.js} +1 -1
  70. package/dist/chunk-BRWCWZE3.js +2 -0
  71. package/dist/{chunk-X7S7IGCV.js → chunk-BXJNL22L.js} +1 -1
  72. package/dist/chunk-BZEW7CSM.js +3 -0
  73. package/dist/{chunk-Z24SD2EJ.js → chunk-C3DMMAFP.js} +1 -1
  74. package/dist/{chunk-DQXQJJOP.js → chunk-C466XER3.js} +2 -2
  75. package/dist/{chunk-BLVDV3QQ.js → chunk-C4UME2PA.js} +1 -1
  76. package/dist/chunk-CBEMXSWF.js +2 -0
  77. package/dist/{chunk-6QCCTZO3.js → chunk-CBPACEYQ.js} +1 -1
  78. package/dist/{chunk-MD3RABID.js → chunk-CJGQFKLJ.js} +1 -1
  79. package/dist/{chunk-YVVFXBT5.js → chunk-CQBLJTDU.js} +1 -1
  80. package/dist/{chunk-X2MDL6S4.js → chunk-CVVUBCB7.js} +1 -1
  81. package/dist/{chunk-35BG2EMW.js → chunk-E3C4OWSD.js} +1 -1
  82. package/dist/{chunk-ERRIDBE7.js → chunk-EIQSXD7B.js} +1 -1
  83. package/dist/{chunk-YPGZ5E4I.js → chunk-EP4WGGMY.js} +1 -1
  84. package/dist/{chunk-GAKBHNC4.js → chunk-EUGFABAS.js} +1 -1
  85. package/dist/{chunk-HBLHKQR7.js → chunk-F4GWIX66.js} +1 -1
  86. package/dist/{chunk-SALZ6WSF.js → chunk-F4XCCOWC.js} +1 -1
  87. package/dist/{chunk-NHGPMYM3.js → chunk-FHULYIG3.js} +1 -1
  88. package/dist/{chunk-7RELCXRW.js → chunk-FKA5SWWF.js} +1 -1
  89. package/dist/{chunk-OCVDMZWB.js → chunk-FLGOQ6Q6.js} +1 -1
  90. package/dist/{chunk-YILRYMMG.js → chunk-FNBHP75S.js} +1 -1
  91. package/dist/{chunk-JBKHX5ES.js → chunk-FOURJ24E.js} +1 -1
  92. package/dist/{chunk-DC5F2ADJ.js → chunk-FOUUD3LI.js} +1 -1
  93. package/dist/{chunk-IEHJG6J4.js → chunk-FP6JCXOS.js} +1 -1
  94. package/dist/{chunk-ZDCXWEQG.js → chunk-GRQKMOKE.js} +1 -1
  95. package/dist/{chunk-XKOVEMVZ.js → chunk-H23ZMHHC.js} +1 -1
  96. package/dist/{chunk-E4GIGM5V.js → chunk-H6IPGZTP.js} +1 -1
  97. package/dist/{chunk-MINDIQET.js → chunk-HBGYEA3O.js} +1 -1
  98. package/dist/{chunk-KBGMQYMD.js → chunk-HHF7AM3D.js} +1 -1
  99. package/dist/{chunk-PCQK62MP.js → chunk-HTJDMLZS.js} +1 -1
  100. package/dist/{chunk-ZPU3WAC4.js → chunk-HY5BBSYX.js} +1 -1
  101. package/dist/{chunk-TM6VLC6V.js → chunk-IPIARGHE.js} +1 -1
  102. package/dist/{chunk-M2E5CPPV.js → chunk-IPXITNFD.js} +1 -1
  103. package/dist/{chunk-NI3TIAD7.js → chunk-IT6M7OMG.js} +1 -1
  104. package/dist/{chunk-Y3RJHWNK.js → chunk-ITG5WMQG.js} +1 -1
  105. package/dist/{chunk-WEJR2V7R.js → chunk-J3XOEMKO.js} +1 -1
  106. package/dist/{chunk-OHGL4GEJ.js → chunk-J3YID4A5.js} +1 -1
  107. package/dist/{chunk-OCMPWCKQ.js → chunk-J44FV6CH.js} +1 -1
  108. package/dist/{chunk-3MD2XLE7.js → chunk-J5D4IGAM.js} +9 -8
  109. package/dist/{chunk-6QH75BPJ.js → chunk-J5QFO7LW.js} +1 -1
  110. package/dist/{chunk-GJXO6FF7.js → chunk-JBUKEIYL.js} +1 -1
  111. package/dist/{chunk-EJGCIGQY.js → chunk-JGQ3VB44.js} +1 -1
  112. package/dist/{chunk-GEZVC4S3.js → chunk-JM6AKCN4.js} +1 -1
  113. package/dist/{chunk-3KY7HHQU.js → chunk-JSSM2TWY.js} +1 -1
  114. package/dist/{chunk-3ZC7GSMM.js → chunk-JVXEAO62.js} +1 -1
  115. package/dist/{chunk-TM45NPWL.js → chunk-JYH7CTF7.js} +1 -1
  116. package/dist/{chunk-YNDELIXL.js → chunk-JZ7GFPKZ.js} +1 -1
  117. package/dist/{chunk-CTHUX7O4.js → chunk-KUSHV5SR.js} +1 -1
  118. package/dist/{chunk-LTPOMMAB.js → chunk-LB5NIDW6.js} +1 -1
  119. package/dist/{chunk-SIHX5FW5.js → chunk-LJKTIKZY.js} +1 -1
  120. package/dist/{chunk-LPJKNX6D.js → chunk-LMOW4NM5.js} +1 -1
  121. package/dist/{chunk-WIVKLNIO.js → chunk-LPJX5L3F.js} +1 -1
  122. package/dist/{chunk-HRIDAK6Y.js → chunk-LWP7E5FU.js} +1 -1
  123. package/dist/{chunk-YWWVF5OU.js → chunk-LXYXCANZ.js} +1 -1
  124. package/dist/{chunk-35WUYKGO.js → chunk-MAQVRBUQ.js} +1 -1
  125. package/dist/{chunk-NPAUSUNM.js → chunk-MBNSCXVK.js} +1 -1
  126. package/dist/{chunk-ZMIKNNO6.js → chunk-MIQ6J5YG.js} +1 -1
  127. package/dist/chunk-MTMHB5LF.js +2 -0
  128. package/dist/{chunk-RNHSULQM.js → chunk-MUL2QFG2.js} +1 -1
  129. package/dist/{chunk-MEBEVHGP.js → chunk-N4XUGIAK.js} +1 -1
  130. package/dist/{chunk-GQAWZEA4.js → chunk-NAUIJF72.js} +1 -1
  131. package/dist/{chunk-PB6RXDWQ.js → chunk-NFDVDEOH.js} +2 -2
  132. package/dist/{chunk-LHJSIHLC.js → chunk-NGBXXBHP.js} +1 -1
  133. package/dist/{chunk-YCVEI7BT.js → chunk-NIBNVPAE.js} +1 -1
  134. package/dist/chunk-NKJRAQ6L.js +6 -0
  135. package/dist/{chunk-OZNYQONA.js → chunk-NNVHWFLI.js} +3 -3
  136. package/dist/{chunk-7SU53QGU.js → chunk-NZ7UCAN6.js} +1 -1
  137. package/dist/{chunk-7V34ZMMS.js → chunk-OKCVG7AG.js} +1 -1
  138. package/dist/{chunk-LZGAFKYH.js → chunk-OMCJD4LH.js} +1 -1
  139. package/dist/{chunk-VO2NNXKR.js → chunk-OPR5XIPT.js} +1 -1
  140. package/dist/{chunk-EZMRWXRT.js → chunk-OVB5GVRB.js} +1 -1
  141. package/dist/{chunk-LV7224DG.js → chunk-PCL2FYPE.js} +1 -1
  142. package/dist/{chunk-AVLYSNEG.js → chunk-PE3CEG6E.js} +1 -1
  143. package/dist/{chunk-MEMXFTLD.js → chunk-PEHVBCXM.js} +1 -1
  144. package/dist/{chunk-6HRNG4CK.js → chunk-PKXWYYVK.js} +1 -1
  145. package/dist/{chunk-YQZ736IQ.js → chunk-PSBR2LVL.js} +1 -1
  146. package/dist/{chunk-R6TFRAMZ.js → chunk-PUNFWBRW.js} +1 -1
  147. package/dist/{chunk-7Y55CO42.js → chunk-PZOQ2IQK.js} +1 -1
  148. package/dist/{chunk-SMGRXKXX.js → chunk-Q4QCSO6Y.js} +1 -1
  149. package/dist/{chunk-TUSG7DIL.js → chunk-QJ5XHVS5.js} +1 -1
  150. package/dist/{chunk-TAY7J5VS.js → chunk-QLGQDNA3.js} +1 -1
  151. package/dist/{chunk-QEM5ZRDN.js → chunk-QRUAI2ST.js} +1 -1
  152. package/dist/{chunk-C4KAPGBS.js → chunk-QWEQ742S.js} +3 -3
  153. package/dist/{chunk-Z47ZEFH7.js → chunk-R6S4EJ5R.js} +1 -1
  154. package/dist/{chunk-WE7HRAGO.js → chunk-RHQLDNZL.js} +1 -1
  155. package/dist/{chunk-3RO2YGKH.js → chunk-RM5ZVDVR.js} +1 -1
  156. package/dist/{chunk-N7IWR45S.js → chunk-RU3SWHRE.js} +1 -1
  157. package/dist/{chunk-OBNVGD5H.js → chunk-S5UITUBB.js} +1 -1
  158. package/dist/chunk-SACFQNUH.js +47 -0
  159. package/dist/{chunk-X45RZIAJ.js → chunk-SDIHDYWT.js} +1 -1
  160. package/dist/{chunk-AHT2ORJT.js → chunk-SFHDRKUX.js} +1 -1
  161. package/dist/{chunk-OTMHCHH6.js → chunk-SLISNOG6.js} +1 -1
  162. package/dist/{chunk-T77LTLAD.js → chunk-SULRMI2J.js} +1 -1
  163. package/dist/{chunk-OOGKX4Y6.js → chunk-TC2PHBPH.js} +1 -1
  164. package/dist/{chunk-HVOXMCKE.js → chunk-TCK7WR3M.js} +1 -1
  165. package/dist/{chunk-FOLUB336.js → chunk-TFSWG7AS.js} +1 -1
  166. package/dist/{chunk-PRBWZXFA.js → chunk-TOOJTCON.js} +6 -6
  167. package/dist/chunk-TPCW5OU5.js +3 -0
  168. package/dist/chunk-U5V3L5QH.js +2 -0
  169. package/dist/{chunk-LXK4B2FE.js → chunk-UJYC2XDD.js} +1 -1
  170. package/dist/chunk-UV7FPIBL.js +2 -0
  171. package/dist/{chunk-23DKB2MT.js → chunk-UVL6XQHU.js} +1 -1
  172. package/dist/{chunk-M7A66MSK.js → chunk-UWEBI76C.js} +1 -1
  173. package/dist/{chunk-PTLOOVV4.js → chunk-UWQ4KXLB.js} +1 -1
  174. package/dist/{chunk-ZCBOHWN3.js → chunk-V24LUINK.js} +1 -1
  175. package/dist/{chunk-ND6OP3O2.js → chunk-V3IWCGZT.js} +1 -1
  176. package/dist/{chunk-YDB72F4K.js → chunk-V4SL74TK.js} +1 -1
  177. package/dist/chunk-VEE2O524.js +34 -0
  178. package/dist/{chunk-VKVYT6KZ.js → chunk-VJRXJJML.js} +2 -2
  179. package/dist/{chunk-NRAPCFI2.js → chunk-VKIUHHNT.js} +2 -2
  180. package/dist/{chunk-QHH42RH5.js → chunk-W3PQMIXE.js} +1 -1
  181. package/dist/{chunk-LLQWEGXD.js → chunk-W5EDS4DF.js} +1 -1
  182. package/dist/{chunk-LUA25RYS.js → chunk-WAC5WISH.js} +1 -1
  183. package/dist/{chunk-W54BX6HC.js → chunk-WCIRLITM.js} +1 -1
  184. package/dist/chunk-WMXBRC4B.js +21 -0
  185. package/dist/{chunk-RQKMSNEU.js → chunk-WTMCDYR3.js} +1 -1
  186. package/dist/{chunk-DXIQVBMI.js → chunk-WZ3FE5MT.js} +1 -1
  187. package/dist/{chunk-GLM5UGTF.js → chunk-X66NIHT4.js} +1 -1
  188. package/dist/{chunk-B7ZX5HEN.js → chunk-XDAFRUAJ.js} +1 -1
  189. package/dist/{chunk-JNPFEBUR.js → chunk-XDAHKZ4J.js} +1 -1
  190. package/dist/chunk-XJV5SF3X.js +26 -0
  191. package/dist/{chunk-ZCL7XIVS.js → chunk-XKJZG4GR.js} +1 -1
  192. package/dist/{chunk-EBJW6POT.js → chunk-XRJH4UF3.js} +1 -1
  193. package/dist/chunk-XTQUCCJH.js +2 -0
  194. package/dist/chunk-Y3RDLUH5.js +7 -0
  195. package/dist/{chunk-SVIIUKJ2.js → chunk-Y7GSOKXS.js} +1 -1
  196. package/dist/{chunk-UJ37XGSP.js → chunk-YF22VTR5.js} +3 -3
  197. package/dist/chunk-YIBLZIXF.js +13 -0
  198. package/dist/{chunk-2JFRN62I.js → chunk-YLI7DQMJ.js} +2 -2
  199. package/dist/chunk-YQXOD7SV.js +102 -0
  200. package/dist/{chunk-4UX5N7YI.js → chunk-YTWBNACA.js} +1 -1
  201. package/dist/{chunk-KCXLRR3Q.js → chunk-YUFXE6WU.js} +1 -1
  202. package/dist/{chunk-SSOUYKVG.js → chunk-ZIRSTOEV.js} +1 -1
  203. package/dist/command-span-HZSKIZH7.js +2 -0
  204. package/dist/commands-TRAUFCRZ.js +2 -0
  205. package/dist/{committer-UO3B3S5Y.js → committer-L2HXEODA.js} +1 -1
  206. package/dist/{config-7WTZPMAH.js → config-O3BWQUP4.js} +1 -1
  207. package/dist/cover-cmd-SAWVP7TL.js +2 -0
  208. package/dist/{credentials-5WIFF5DG.js → credentials-NNNODDXF.js} +1 -1
  209. package/dist/{deps-bundle-BLLJ2BQ4.js → deps-bundle-CXKBCA7W.js} +1 -1
  210. package/dist/{deps-resolve-WQ6J6RLI.js → deps-resolve-K7XNTRZX.js} +1 -1
  211. package/dist/design-chat-S4KYE6PP.js +2 -0
  212. package/dist/{design-committer-7YIPFKMO.js → design-committer-ZKNW5LUS.js} +1 -1
  213. package/dist/design-headless-DDAFAJNR.js +2 -0
  214. package/dist/design-remote-UITWJ72Q.js +3 -0
  215. package/dist/device-env-SBTHFSVK.js +2 -0
  216. package/dist/dispatch-BGH5PVZ4.js +2 -0
  217. package/dist/doctor-SRMLENYN.js +2 -0
  218. package/dist/{docx-convert-DO5AQYD3.js → docx-convert-PA5S2S7P.js} +1 -1
  219. package/dist/{dossier-5XKNAK6Q.js → dossier-B6KBSRJY.js} +1 -1
  220. package/dist/evidence-FOWW3MOS.js +2 -0
  221. package/dist/evolve-cmd-MDK2H4JY.js +2 -0
  222. package/dist/evolve-remote-4G7YFC5H.js +2 -0
  223. package/dist/exit-manager-UZ7DGXS4.js +2 -0
  224. package/dist/{explain-cmd-KNDORU2D.js → explain-cmd-A5YMPXAJ.js} +1 -1
  225. package/dist/explain-cmd-Q4NLNJFB.js +12 -0
  226. package/dist/explore-MWUMVGRM.js +2 -0
  227. package/dist/explore-context-tty-QLMZGYBX.js +2 -0
  228. package/dist/explore-entry-QMCVGRP4.js +6 -0
  229. package/dist/{explore-live-XIWWUV52.js → explore-live-QIET6WO4.js} +1 -1
  230. package/dist/{explore-run-tty-M56I23IF.js → explore-run-tty-6UTBRCEF.js} +2 -2
  231. package/dist/{extract-bind-LZ22VFKB.js → extract-bind-UTERWZMW.js} +3 -3
  232. package/dist/extract-chat-4WBNRVPG.js +2 -0
  233. package/dist/{extract-cmd-46E2XDWZ.js → extract-cmd-SYZX6CML.js} +2 -2
  234. package/dist/extract-headless-QBF77JWP.js +2 -0
  235. package/dist/{feeder-NGWIPZ26.js → feeder-VAY4NYBX.js} +1 -1
  236. package/dist/folder-flags-IJ556UET.js +2 -0
  237. package/dist/gaps-cmd-E55OGZ7P.js +3 -0
  238. package/dist/gate-5UIJVMHL.js +2 -0
  239. package/dist/gate-VJ7W5QIH.js +2 -0
  240. package/dist/{generate-headless-HXAVEAEZ.js → generate-headless-VYD2QIUO.js} +3 -3
  241. package/dist/hold-passthrough-ZHOC2Q26.js +2 -0
  242. package/dist/identity-66TGWITQ.js +2 -0
  243. package/dist/{impact-cmd-TJTUFAFO.js → impact-cmd-3P6SKFJC.js} +2 -2
  244. package/dist/index.js +185 -184
  245. package/dist/ingest-6UQGSQYU.js +2 -0
  246. package/dist/ingest-cmd-HMTLO5MB.js +8 -0
  247. package/dist/ingest-remote-NIW5VAGW.js +2 -0
  248. package/dist/install-KJDAGU2R.js +2 -0
  249. package/dist/{interactive-bind-SOD7VTAY.js → interactive-bind-K3ZQFHLH.js} +4 -4
  250. package/dist/{interactive-remote-7ZSTI66T.js → interactive-remote-SGM76D6M.js} +2 -2
  251. package/dist/lane-EHU4JRRU.js +2 -0
  252. package/dist/lattice-auth-DCAVEQKY.js +2 -0
  253. package/dist/lifecycle-cmd-Y5DH2PL5.js +2 -0
  254. package/dist/list-cmd-RYHICCUV.js +3 -0
  255. package/dist/list-commands-QFTIQE6Q.js +2 -0
  256. package/dist/{list-remote-EFCET42K.js → list-remote-PWAQBF57.js} +1 -1
  257. package/dist/{locks-cmd-AZKCSGHI.js → locks-cmd-76IU4JB7.js} +1 -1
  258. package/dist/{logical-ids-74PLU3VR.js → logical-ids-YMNV2MDB.js} +1 -1
  259. package/dist/login-flow-W7RAVXSD.js +2 -0
  260. package/dist/maintenance-cmd-JNP2KCSI.js +2 -0
  261. package/dist/mobile-prompts-SP2RULD7.js +2 -0
  262. package/dist/onboarding-YPIKXNYA.js +5 -0
  263. package/dist/open-provider-LXCPVNUU.js +2 -0
  264. package/dist/{pdf-convert-YB6PJFMI.js → pdf-convert-N2C3KB4Q.js} +1 -1
  265. package/dist/persist-recorded-session-BWGA7WXR.js +3 -0
  266. package/dist/phase-seed-G5JSYKSL.js +2 -0
  267. package/dist/pipeline-YE4IRKQX.js +2 -0
  268. package/dist/{policy-commands-4PUGESCW.js → policy-commands-MSJIPHDB.js} +1 -1
  269. package/dist/prepare-target-G7LU4LYX.js +2 -0
  270. package/dist/pull-cmd-G3PVSSFP.js +2 -0
  271. package/dist/pull-route-5JQUUSU7.js +2 -0
  272. package/dist/readmodel-FARAAPUU.js +2 -0
  273. package/dist/real-device-run-425XK527.js +2 -0
  274. package/dist/reconcile-cmd-QJBYZVUB.js +5 -0
  275. package/dist/reconcile-deps-TILDRCHG.js +2 -0
  276. package/dist/{reconcile-remote-3W6ZTO3G.js → reconcile-remote-JMV26DLX.js} +2 -2
  277. package/dist/recording-banner-VZ67EWWQ.js +2 -0
  278. package/dist/registry-3YMKU5GC.js +2 -0
  279. package/dist/remote-entry-6LQRYR5F.js +2 -0
  280. package/dist/remote-mode-35BQUMEL.js +4 -0
  281. package/dist/remote-words-QXVFVHOB.js +2 -0
  282. package/dist/{require-project-folder-3DTI2CVB.js → require-project-folder-O2XCXDRE.js} +1 -1
  283. package/dist/resolve-run-intent-QCRZPYXM.js +2 -0
  284. package/dist/{resolver-CDF7QKVD.js → resolver-LWXOB7PH.js} +1 -1
  285. package/dist/revert-F6MKJ73M.js +2 -0
  286. package/dist/review-cmd-PYU7YCAC.js +5 -0
  287. package/dist/run-EABFRFOF.js +2 -0
  288. package/dist/run-LX3ARF53.js +2 -0
  289. package/dist/run-remote-PS45MTHW.js +2 -0
  290. package/dist/run-startup-gate-YBQB2JLF.js +2 -0
  291. package/dist/run-test-md-XYOCVA6F.js +20 -0
  292. package/dist/session-worker.js +2 -2
  293. package/dist/{sessions-cmd-TLUITRG5.js → sessions-cmd-WUWZYZJW.js} +2 -2
  294. package/dist/{sessions-remote-INO7AWKB.js → sessions-remote-4J7ITZB4.js} +1 -1
  295. package/dist/{skill-installer-7JH5QCJF.js → skill-installer-54ZAFNOB.js} +1 -1
  296. package/dist/store-2F26FIUS.js +2 -0
  297. package/dist/store-choice-ZE7AZMRC.js +2 -0
  298. package/dist/store-guard-X5FIEZWZ.js +2 -0
  299. package/dist/{store-site-K5NHLI7D.js → store-site-AFXB6SBW.js} +1 -1
  300. package/dist/{stream-warnings-GM7YEOVG.js → stream-warnings-I5LUWVFU.js} +1 -1
  301. package/dist/support-id-RISKXA53.js +2 -0
  302. package/dist/sync-cmd-TAVE44DU.js +2 -0
  303. package/dist/sync-setup-M65RX34Y.js +2 -0
  304. package/dist/tcg-generate-OXZF7TNQ.js +2 -0
  305. package/dist/{test-definition-53XNBEDE.js → test-definition-GXEKFRRB.js} +1 -1
  306. package/dist/testmd-actions-4OHRME2Z.js +2 -0
  307. package/dist/{testmd-sync-LYHEXWCT.js → testmd-sync-HM24JCS7.js} +1 -1
  308. package/dist/token-refresh-3SEDPIXO.js +2 -0
  309. package/dist/{use-case-ref-44BPIP4N.js → use-case-ref-E3PJDHQB.js} +1 -1
  310. package/dist/{validate-basic-66XDPA3S.js → validate-basic-HWDR665U.js} +1 -1
  311. package/dist/verdicts-KB6YTIY6.js +2 -0
  312. package/dist/{version-check-SHNVYTMU.js → version-check-DRE5KT7F.js} +1 -1
  313. package/dist/{view-cmd-QOB3O6YW.js → view-cmd-3UKV3YEX.js} +1 -1
  314. package/dist/walk-session-W6OLG5NT.js +2 -0
  315. package/dist/with-telemetry-BF4BGK5S.js +2 -0
  316. package/package.json +11 -11
  317. package/dist/ChatSurface-Z26BOE5U.js +0 -2
  318. package/dist/ChromeProfilePicker-ODRIAXL3.js +0 -2
  319. package/dist/EvidenceViewOffer-6344EX74.js +0 -2
  320. package/dist/FolderPicker-4PCYHE75.js +0 -2
  321. package/dist/InfoBox-NJ2DL7YC.js +0 -2
  322. package/dist/LinksBox-HNDNFVUT.js +0 -2
  323. package/dist/ProfilesView-DEJKJOHY.js +0 -2
  324. package/dist/ProjectPicker-DTWMWOH7.js +0 -2
  325. package/dist/SaveSessionPrompt-3GCLB3ZT.js +0 -2
  326. package/dist/SingleShotApp-HMOXO5DW.js +0 -2
  327. package/dist/SummaryBox-7PPDMSSM.js +0 -2
  328. package/dist/TestMdRunView-QLKRUU4V.js +0 -2
  329. package/dist/TestrunEvidenceTable-T2JUB4TE.js +0 -2
  330. package/dist/app-download-GKRF2EIM.js +0 -2
  331. package/dist/bind-SSHAZAB3.js +0 -2
  332. package/dist/bootstrap-XGKU4WXB.js +0 -2
  333. package/dist/chat-committer-ZKEKJA2R.js +0 -2
  334. package/dist/chat-controller-FXRJXUG3.js +0 -2
  335. package/dist/child-JHYENXE7.js +0 -2
  336. package/dist/chunk-2RBMQTYS.js +0 -26
  337. package/dist/chunk-5F5IVART.js +0 -8
  338. package/dist/chunk-6SD4XTYC.js +0 -6
  339. package/dist/chunk-7YV2FCN4.js +0 -3
  340. package/dist/chunk-A2DODRHG.js +0 -2
  341. package/dist/chunk-BJO6J5X2.js +0 -3
  342. package/dist/chunk-DIOK3SER.js +0 -34
  343. package/dist/chunk-DREQ3RAA.js +0 -2
  344. package/dist/chunk-HC6VLPUB.js +0 -5
  345. package/dist/chunk-J4FIESTB.js +0 -2
  346. package/dist/chunk-NZJSGINB.js +0 -47
  347. package/dist/chunk-SXRHKXSE.js +0 -2
  348. package/dist/chunk-UJLULWSR.js +0 -21
  349. package/dist/chunk-ULIIYKZB.js +0 -7
  350. package/dist/chunk-UXGMKRS4.js +0 -102
  351. package/dist/chunk-VO66KP2W.js +0 -2
  352. package/dist/chunk-X52YIWGG.js +0 -13
  353. package/dist/chunk-ZIHQ5JGB.js +0 -18
  354. package/dist/commands-JBFLLT7A.js +0 -2
  355. package/dist/cover-cmd-DU6ZYJFL.js +0 -2
  356. package/dist/design-chat-ZICGVYIH.js +0 -2
  357. package/dist/design-headless-HYWZIIDS.js +0 -2
  358. package/dist/design-remote-HPX4VZ63.js +0 -3
  359. package/dist/device-env-4P4GUVBW.js +0 -2
  360. package/dist/dispatch-BV6XMCN3.js +0 -2
  361. package/dist/doctor-Z2YQ2DBX.js +0 -2
  362. package/dist/evidence-BJIID6VT.js +0 -2
  363. package/dist/evolve-cmd-GZCUSCEK.js +0 -2
  364. package/dist/evolve-remote-LILOAHYH.js +0 -2
  365. package/dist/exit-manager-EGWAZHCR.js +0 -2
  366. package/dist/explain-cmd-LXIVHGN7.js +0 -12
  367. package/dist/explore-SA2P3SGX.js +0 -2
  368. package/dist/explore-context-tty-PERKIWXD.js +0 -2
  369. package/dist/explore-entry-E6EY3VV3.js +0 -6
  370. package/dist/extract-chat-Z64LEAJ5.js +0 -2
  371. package/dist/extract-headless-XLS56LMN.js +0 -2
  372. package/dist/folder-flags-ZIDJVDKX.js +0 -2
  373. package/dist/gaps-cmd-XYOBJVTO.js +0 -3
  374. package/dist/gate-AK44VDHC.js +0 -2
  375. package/dist/gate-NB5CJMTN.js +0 -2
  376. package/dist/hold-passthrough-JGHWMYDM.js +0 -2
  377. package/dist/identity-HL5CJJXR.js +0 -2
  378. package/dist/ingest-ZHHHBUXR.js +0 -2
  379. package/dist/ingest-cmd-OJSKTSQK.js +0 -8
  380. package/dist/ingest-remote-2WM6PYUW.js +0 -2
  381. package/dist/install-JBWBF3WX.js +0 -2
  382. package/dist/lane-CNGO7LH5.js +0 -2
  383. package/dist/lattice-auth-UQPFQSG7.js +0 -2
  384. package/dist/lifecycle-cmd-DGIO3VAO.js +0 -2
  385. package/dist/list-cmd-HQIN3HX4.js +0 -3
  386. package/dist/list-commands-OFRRBU3D.js +0 -2
  387. package/dist/login-flow-SYKXXDLH.js +0 -2
  388. package/dist/maintenance-cmd-X5247RSJ.js +0 -2
  389. package/dist/mobile-prompts-I66ENBDW.js +0 -2
  390. package/dist/onboarding-6HIP3KW6.js +0 -5
  391. package/dist/open-provider-XDJKT3W3.js +0 -2
  392. package/dist/persist-recorded-session-RSSMTVF3.js +0 -3
  393. package/dist/phase-seed-ZZSJME7M.js +0 -2
  394. package/dist/pipeline-NTJDH5TC.js +0 -2
  395. package/dist/prepare-target-AI3GGZF6.js +0 -2
  396. package/dist/pull-cmd-NRVB5ZN7.js +0 -2
  397. package/dist/pull-route-FWCZW76M.js +0 -2
  398. package/dist/readmodel-TRV4E3MW.js +0 -2
  399. package/dist/real-device-run-NQ7RNH7C.js +0 -2
  400. package/dist/reconcile-cmd-7B7THAFJ.js +0 -5
  401. package/dist/reconcile-deps-UDQBWSLE.js +0 -2
  402. package/dist/recording-banner-WVDTWTSE.js +0 -2
  403. package/dist/registry-PFOSXOIH.js +0 -2
  404. package/dist/remote-entry-BZU4NFNS.js +0 -2
  405. package/dist/remote-mode-NXUKDUXG.js +0 -4
  406. package/dist/remote-words-JRDDNOZ6.js +0 -2
  407. package/dist/resolve-run-intent-QCL7QXIB.js +0 -2
  408. package/dist/revert-QKHPCRT6.js +0 -2
  409. package/dist/review-cmd-XBK3TGRE.js +0 -5
  410. package/dist/run-CSYGVV3D.js +0 -2
  411. package/dist/run-YUHHD54J.js +0 -2
  412. package/dist/run-remote-SFR3F2T5.js +0 -2
  413. package/dist/run-startup-gate-QSFJRYUY.js +0 -2
  414. package/dist/run-test-md-ZSREINDQ.js +0 -20
  415. package/dist/store-X4UK4AP7.js +0 -2
  416. package/dist/store-choice-27HDIFTU.js +0 -2
  417. package/dist/store-guard-ZXKB5DQH.js +0 -2
  418. package/dist/sync-cmd-2PCO7LZA.js +0 -2
  419. package/dist/sync-setup-5WQO73Y5.js +0 -2
  420. package/dist/tcg-generate-DGJD5KSM.js +0 -2
  421. package/dist/testmd-actions-XE2JPQHB.js +0 -2
  422. package/dist/token-refresh-E4FTJVHY.js +0 -2
  423. package/dist/verdicts-PVB7TV5S.js +0 -2
  424. package/dist/walk-session-WIEROYOT.js +0 -2
  425. package/dist/with-telemetry-T2PWI5CY.js +0 -2
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as V}from"./chunk-RTVWQK7I.js";import{a as j,f as q}from"./chunk-PRBWZXFA.js";import{c as H,e as A,g as P}from"./chunk-4KCYNP2K.js";import{c as _}from"./chunk-JNPFEBUR.js";import{a as O}from"./chunk-VZJ6LUXX.js";import{n as L}from"./chunk-DXIQVBMI.js";import{c as h}from"./chunk-BWXLZS5O.js";import{a as I}from"./chunk-GFLB2SHW.js";import{M as S}from"./chunk-PI7OXS62.js";import{o as D}from"./chunk-HYJVYYAZ.js";function F(e,n){try{let s=e.sessions().peek(n);return!s||!L(s,e.sessions().hasBase(n))?!1:(e.sessions().resume(n).complete({ended:"failed",code:"SESSION_KEPT_NOTHING"}),!0)}catch{return!1}}var J=e=>e!==null?{fixCmd:e}:{};function Q(e,n){return e.recordsSince(null).flatMap(o=>{let r=o.design_phase?.phase;return o.sid===n&&typeof r=="string"&&_[r]?[_[r]]:[]}).at(-1)}function X(e,n,s){return e.recordsSince(s).some(o=>o.sid!==n||!o.design_of?!1:o.design_phase?.phase==="tests"||o.nodes.some(r=>r.label==="test"))}async function le(e,n,s){let o=n.enterNested?.("opening the design\u2026")??(()=>{});try{return await Z(e,n,s)}finally{o()}}async function Z(e,n,s){let{force:o=!1,verb:r="design",childSession:d}=e,i=e.resume===!0?d:void 0;if(e.resume===!0&&i===void 0)return n.note("design child not resumed \u2014 a resume needs the child's session"),n.endUnstartedTurn(),2;if(i!==void 0&&F(s.store,i.id))return n.note(`design child ${i.id} kept nothing to resume \u2014 its agent never started; its offer opens again`),n.endUnstartedTurn(),2;let f=(()=>{if(i===void 0)return e.ucRef;try{return s.store.sessions().peek(i.id)?.use_case??e.ucRef}catch{return e.ucRef}})(),y=!1;if(i===void 0)try{let t=H(S(s.store),f);if(!t.ok&&(t.code==="UC_UNREVIEWED"||t.code==="UC_ARCHIVED")){let l=e.confirmUnreviewed??(C=>P(m=>n.ask(m),C)),a=!A(t);if(a||!await l(t))return n.note(t.reviewCmd!==void 0?`design child refused \u2014 approve it first: ${t.reviewCmd}`:"design child refused \u2014 approve it first"),n.endUnstartedTurn(),e.onEnded?.(a?"refused":"declined",a?{code:t.code}:void 0),2;y=!0}}catch{y=!1}let p=(()=>{try{let t=S(s.store),l=t.resolve(f);return(l?t.getNode(l.tip)?.content?.title:void 0)??f}catch{return f}})(),c=d?.id??i?.id,E=i?null:s.store.head(),B=i&&c!==void 0?Q(s.store,c):void 0,W=h(n.state.turns).entries.length,R=()=>h(n.state.turns).entries.filter(t=>t.kind==="test").length,$=R(),T=n.state.credits?.total,K=Date.now();n.ledger({kind:"childOpen",verb:r,subject:p,...d?{sid:d.id}:{},...i?{resumed:!0}:{},...e.replaces?{replaces:e.replaces}:{},...B?{landed:B}:{},...e.evolution?{update:!0}:{},...e.evolution?.changed?{changed:!0}:{}});let M=t=>{let l=Math.max(1,Math.round((Date.now()-K)/1e3)),a=h(n.state.turns).entries.length-W,C=R()-$,m=n.state.credits?.total,w=m!==void 0&&T!==void 0?m-T:m,U=e.evolution!==void 0&&t===0&&c!==void 0&&!s.store.recordsSince(E).some(x=>x.sid===c),G=t===0&&c!==void 0&&!U&&!X(s.store,c,E);if(n.ledger(t===0?{kind:"childClose",verb:r,subject:p,ok:!0,durS:l,...e.evolution?{update:!0}:{},...U?{untouched:!0}:{},...G?{unfinished:!0}:{},...a>0?{results:`${a} item${a===1?"":"s"}`}:{},...C>0?{tests:C}:{},...e.evolution&&c!==void 0?{testsWritten:j(s.store.recordsSince(E).filter(x=>x.sid===c),S(s.store))}:{},...w!==void 0&&w>0?{credits:w}:{}}:{kind:"childClose",verb:r,subject:p,ok:!1,durS:l,exitCode:t,...e.evolution?{update:!0}:{},...J(i!==void 0?D().command("next.resume_child",{sid:i.id}):D().command("next.design_use_case",{use_case:f,force:o||r==="evolve"}))}),e.quietEnding)return;let z=h(n.state.turns).entries.length;n.ledger({kind:"childBack",parentVerb:"extract",context:D().text("chat.child_back",{drafts:z})})},b="",u=1,v=!1,k,g,N=d?.id,Y=(...t)=>(v=!0,s.agent(...t));try{u=await q(i?{resume:i.id,mode:"interactive"}:{useCase:f,force:o,mode:"interactive",...y?{allowUnreviewed:!0}:{},...e.statement?{agentStatement:e.statement}:{},...e.evolution?.because?{because:e.evolution.because}:{},...e.evolution?.changeDelta!==void 0?{changeDelta:e.evolution.changeDelta}:{},...e.evolution?.priorDesign!==void 0?{priorDesign:e.evolution.priorDesign}:{},...d?{sessionId:d.id,registerSession:t=>d.register(t)}:{}},{...s,emit:t=>{!v&&k===void 0&&(k=O(t)??void 0),s.emit?.(V(t,{verb:"design",...N!==void 0?{id:N}:{}}))},agent:Y,ask:t=>n.ask(t),chat:n,nested:!0,out:t=>{b=t},progress:()=>{},isTTY:!0})}catch(t){if(!(e.onHeld&&t instanceof I&&t.code==="SESSION_CLASH"))throw t;g={heldBy:t.extra?.heldBy??null},u=2}finally{let t=u===3&&n.state.status==="pausing";g?n.ledger({kind:"childClose",verb:r,subject:p,ok:!1,durS:0,held:!0}):t&&e.quietEnding||M(u),v||n.endUnstartedTurn(),v&&!t?e.onEnded?.("ran",{exit:u}):g?e.onEnded?.("refused",{code:"SESSION_CLASH"}):k?.final&&e.onEnded?.("refused",{code:k.code})}return g?(e.onHeld(g.heldBy),u):(u!==0&&b&&!e.quietEnding&&n.note(b),u)}export{Q as a,X as b,le as c};
2
+ import{a as V}from"./chunk-RTVWQK7I.js";import{a as j,f as q}from"./chunk-TOOJTCON.js";import{c as H,e as A,g as P}from"./chunk-4KCYNP2K.js";import{c as _}from"./chunk-XDAHKZ4J.js";import{a as O}from"./chunk-VZJ6LUXX.js";import{n as L}from"./chunk-WZ3FE5MT.js";import{c as h}from"./chunk-BWXLZS5O.js";import{a as I}from"./chunk-GFLB2SHW.js";import{M as S}from"./chunk-5EAJO372.js";import{o as D}from"./chunk-HYJVYYAZ.js";function F(e,n){try{let s=e.sessions().peek(n);return!s||!L(s,e.sessions().hasBase(n))?!1:(e.sessions().resume(n).complete({ended:"failed",code:"SESSION_KEPT_NOTHING"}),!0)}catch{return!1}}var J=e=>e!==null?{fixCmd:e}:{};function Q(e,n){return e.recordsSince(null).flatMap(o=>{let r=o.design_phase?.phase;return o.sid===n&&typeof r=="string"&&_[r]?[_[r]]:[]}).at(-1)}function X(e,n,s){return e.recordsSince(s).some(o=>o.sid!==n||!o.design_of?!1:o.design_phase?.phase==="tests"||o.nodes.some(r=>r.label==="test"))}async function le(e,n,s){let o=n.enterNested?.("opening the design\u2026")??(()=>{});try{return await Z(e,n,s)}finally{o()}}async function Z(e,n,s){let{force:o=!1,verb:r="design",childSession:d}=e,i=e.resume===!0?d:void 0;if(e.resume===!0&&i===void 0)return n.note("design child not resumed \u2014 a resume needs the child's session"),n.endUnstartedTurn(),2;if(i!==void 0&&F(s.store,i.id))return n.note(`design child ${i.id} kept nothing to resume \u2014 its agent never started; its offer opens again`),n.endUnstartedTurn(),2;let f=(()=>{if(i===void 0)return e.ucRef;try{return s.store.sessions().peek(i.id)?.use_case??e.ucRef}catch{return e.ucRef}})(),y=!1;if(i===void 0)try{let t=H(S(s.store),f);if(!t.ok&&(t.code==="UC_UNREVIEWED"||t.code==="UC_ARCHIVED")){let l=e.confirmUnreviewed??(C=>P(m=>n.ask(m),C)),a=!A(t);if(a||!await l(t))return n.note(t.reviewCmd!==void 0?`design child refused \u2014 approve it first: ${t.reviewCmd}`:"design child refused \u2014 approve it first"),n.endUnstartedTurn(),e.onEnded?.(a?"refused":"declined",a?{code:t.code}:void 0),2;y=!0}}catch{y=!1}let p=(()=>{try{let t=S(s.store),l=t.resolve(f);return(l?t.getNode(l.tip)?.content?.title:void 0)??f}catch{return f}})(),c=d?.id??i?.id,E=i?null:s.store.head(),B=i&&c!==void 0?Q(s.store,c):void 0,W=h(n.state.turns).entries.length,R=()=>h(n.state.turns).entries.filter(t=>t.kind==="test").length,$=R(),T=n.state.credits?.total,K=Date.now();n.ledger({kind:"childOpen",verb:r,subject:p,...d?{sid:d.id}:{},...i?{resumed:!0}:{},...e.replaces?{replaces:e.replaces}:{},...B?{landed:B}:{},...e.evolution?{update:!0}:{},...e.evolution?.changed?{changed:!0}:{}});let M=t=>{let l=Math.max(1,Math.round((Date.now()-K)/1e3)),a=h(n.state.turns).entries.length-W,C=R()-$,m=n.state.credits?.total,w=m!==void 0&&T!==void 0?m-T:m,U=e.evolution!==void 0&&t===0&&c!==void 0&&!s.store.recordsSince(E).some(x=>x.sid===c),G=t===0&&c!==void 0&&!U&&!X(s.store,c,E);if(n.ledger(t===0?{kind:"childClose",verb:r,subject:p,ok:!0,durS:l,...e.evolution?{update:!0}:{},...U?{untouched:!0}:{},...G?{unfinished:!0}:{},...a>0?{results:`${a} item${a===1?"":"s"}`}:{},...C>0?{tests:C}:{},...e.evolution&&c!==void 0?{testsWritten:j(s.store.recordsSince(E).filter(x=>x.sid===c),S(s.store))}:{},...w!==void 0&&w>0?{credits:w}:{}}:{kind:"childClose",verb:r,subject:p,ok:!1,durS:l,exitCode:t,...e.evolution?{update:!0}:{},...J(i!==void 0?D().command("next.resume_child",{sid:i.id}):D().command("next.design_use_case",{use_case:f,force:o||r==="evolve"}))}),e.quietEnding)return;let z=h(n.state.turns).entries.length;n.ledger({kind:"childBack",parentVerb:"extract",context:D().text("chat.child_back",{drafts:z})})},b="",u=1,v=!1,k,g,N=d?.id,Y=(...t)=>(v=!0,s.agent(...t));try{u=await q(i?{resume:i.id,mode:"interactive"}:{useCase:f,force:o,mode:"interactive",...y?{allowUnreviewed:!0}:{},...e.statement?{agentStatement:e.statement}:{},...e.evolution?.because?{because:e.evolution.because}:{},...e.evolution?.changeDelta!==void 0?{changeDelta:e.evolution.changeDelta}:{},...e.evolution?.priorDesign!==void 0?{priorDesign:e.evolution.priorDesign}:{},...d?{sessionId:d.id,registerSession:t=>d.register(t)}:{}},{...s,emit:t=>{!v&&k===void 0&&(k=O(t)??void 0),s.emit?.(V(t,{verb:"design",...N!==void 0?{id:N}:{}}))},agent:Y,ask:t=>n.ask(t),chat:n,nested:!0,out:t=>{b=t},progress:()=>{},isTTY:!0})}catch(t){if(!(e.onHeld&&t instanceof I&&t.code==="SESSION_CLASH"))throw t;g={heldBy:t.extra?.heldBy??null},u=2}finally{let t=u===3&&n.state.status==="pausing";g?n.ledger({kind:"childClose",verb:r,subject:p,ok:!1,durS:0,held:!0}):t&&e.quietEnding||M(u),v||n.endUnstartedTurn(),v&&!t?e.onEnded?.("ran",{exit:u}):g?e.onEnded?.("refused",{code:"SESSION_CLASH"}):k?.final&&e.onEnded?.("refused",{code:k.code})}return g?(e.onHeld(g.heldBy),u):(u!==0&&b&&!e.quietEnding&&n.note(b),u)}export{Q as a,X as b,le as c};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as m}from"./chunk-PVN64537.js";import{e as y}from"./chunk-ZAQGIC33.js";import{b as d}from"./chunk-ZCBOHWN3.js";function g(t={}){let a=t.readStore??C,s=t.readLis??w;return{async controller(){let e=await a();return{token:e.token,...e.basic?{basic:e.basic}:{}}},async lis(){return s()}}}var A=()=>C(!0),_=g(),P=8e3;function f(){return y("warn: session auth may expire during long runs \u2014 if that happens, run `kane-cli login` and retry","AUTH_EXCHANGE_FAILED"),null}async function h(t,a,s=!1){try{let[{getEnvironment:e},{ControllerClient:r}]=await Promise.all([import("./config-7WTZPMAH.js"),import("./controller-client-PB3AZAGG.js")]),o=new r(e(t).controllerBaseUrl,a),i;try{let n=await Promise.race([o.getTmsCredentials().catch(()=>null),new Promise(c=>{i=setTimeout(()=>c(null),P)})]);if(typeof n?.username!="string"||!n.username||typeof n.access_key!="string"||!n.access_key)return s?null:f();try{let[{refreshIdentitySnapshot:c},{telemetryEnvName:u}]=await Promise.all([import("./identity-HL5CJJXR.js"),import("./bootstrap-XGKU4WXB.js")]);await c(u(),n)}catch{}return{username:n.username,accessKey:n.access_key}}finally{clearTimeout(i)}}catch{return s?null:f()}}var l=null;function E(t){l=t===null?null:{username:t.username,accessKey:t.accessKey}}async function C(t=!1){if(l!==null)return{token:null,basic:{...l}};let[{CredentialsManager:a},{refreshOAuthToken:s}]=await Promise.all([import("./credentials-5WIFF5DG.js"),import("./token-refresh-E4FTJVHY.js")]),e=new a,r=d(),o=e.getActiveProfile()??"default",i=e.loadBasicAuth(o,r);if(i)return{token:null,basic:{username:i.username,accessKey:i.access_key}};let n=e.loadCredentials(o,r);if(!n)throw new m("Not authenticated \u2014 no credentials found","not_authenticated");try{await s({creds:e,profile:o,env:r,credentials:n})}catch{}let c=e.loadCredentials(o,r)??n;if(typeof c.access_token!="string")throw new m("Not authenticated \u2014 no credentials found","not_authenticated");let u=c.access_token,p=await h(r,u,t);return{token:u,...p?{basic:p}:{}}}async function w(){if(l!==null)return{basic:Buffer.from(`${l.username}:${l.accessKey}`,"utf8").toString("base64")};let{CredentialsManager:t}=await import("./credentials-5WIFF5DG.js"),a=new t,s=d(),e=a.loadCredentials(a.getActiveProfile()??"default",s);if(typeof e?.access_token!="string")return{};let r=await h(s,e.access_token,!0);return r?{basic:Buffer.from(`${r.username}:${r.accessKey}`,"utf8").toString("base64")}:{}}export{A as a,_ as b,E as c};
2
+ import{a as m}from"./chunk-PVN64537.js";import{e as y}from"./chunk-ZAQGIC33.js";import{b as d}from"./chunk-V24LUINK.js";function g(t={}){let a=t.readStore??C,s=t.readLis??w;return{async controller(){let e=await a();return{token:e.token,...e.basic?{basic:e.basic}:{}}},async lis(){return s()}}}var A=()=>C(!0),_=g(),P=8e3;function f(){return y("warn: session auth may expire during long runs \u2014 if that happens, run `kane-cli login` and retry","AUTH_EXCHANGE_FAILED"),null}async function h(t,a,s=!1){try{let[{getEnvironment:e},{ControllerClient:r}]=await Promise.all([import("./config-O3BWQUP4.js"),import("./controller-client-PB3AZAGG.js")]),o=new r(e(t).controllerBaseUrl,a),i;try{let n=await Promise.race([o.getTmsCredentials().catch(()=>null),new Promise(c=>{i=setTimeout(()=>c(null),P)})]);if(typeof n?.username!="string"||!n.username||typeof n.access_key!="string"||!n.access_key)return s?null:f();try{let[{refreshIdentitySnapshot:c},{telemetryEnvName:u}]=await Promise.all([import("./identity-66TGWITQ.js"),import("./bootstrap-A2O4UZUJ.js")]);await c(u(),n)}catch{}return{username:n.username,accessKey:n.access_key}}finally{clearTimeout(i)}}catch{return s?null:f()}}var l=null;function E(t){l=t===null?null:{username:t.username,accessKey:t.accessKey}}async function C(t=!1){if(l!==null)return{token:null,basic:{...l}};let[{CredentialsManager:a},{refreshOAuthToken:s}]=await Promise.all([import("./credentials-NNNODDXF.js"),import("./token-refresh-3SEDPIXO.js")]),e=new a,r=d(),o=e.getActiveProfile()??"default",i=e.loadBasicAuth(o,r);if(i)return{token:null,basic:{username:i.username,accessKey:i.access_key}};let n=e.loadCredentials(o,r);if(!n)throw new m("Not authenticated \u2014 no credentials found","not_authenticated");try{await s({creds:e,profile:o,env:r,credentials:n})}catch{}let c=e.loadCredentials(o,r)??n;if(typeof c.access_token!="string")throw new m("Not authenticated \u2014 no credentials found","not_authenticated");let u=c.access_token,p=await h(r,u,t);return{token:u,...p?{basic:p}:{}}}async function w(){if(l!==null)return{basic:Buffer.from(`${l.username}:${l.accessKey}`,"utf8").toString("base64")};let{CredentialsManager:t}=await import("./credentials-NNNODDXF.js"),a=new t,s=d(),e=a.loadCredentials(a.getActiveProfile()??"default",s);if(typeof e?.access_token!="string")return{};let r=await h(s,e.access_token,!0);return r?{basic:Buffer.from(`${r.username}:${r.accessKey}`,"utf8").toString("base64")}:{}}export{A as a,_ as b,E as c};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{f as s}from"./chunk-ZCRZFAOT.js";import o from"fs";import h from"path";import{execSync as p}from"child_process";import{readFileSync as c}from"fs";import{createHash as f}from"crypto";import{hostname as d,platform as g,arch as m}from"os";var a=null;function u(){return a||(a=l(),a)}function l(){let i=g();if(i==="darwin")try{let n=p("ioreg -rd1 -c IOPlatformExpertDevice",{encoding:"utf-8",timeout:5e3}).match(/"IOPlatformUUID"\s*=\s*"([^"]+)"/);if(n?.[1])return n[1]}catch{}if(i==="linux")try{let r=c("/etc/machine-id","utf-8").trim();if(r)return r}catch{}let t=`${d()}:${i}:${m()}`;return f("sha256").update(t).digest("hex").slice(0,32)}var y=new Set(["org_id","user_id","plan","user_type"]);function k(i){let t={machine_id:u(),env:i};try{let r=JSON.parse(o.readFileSync(s(i),"utf8"));for(let[n,e]of Object.entries(r))y.has(n)&&typeof e=="string"&&e.length>0&&e.length<=128&&(t[n]=e)}catch{}return t}async function A(i,t){if(!t)return;let r={};if(t.org_id!==void 0&&t.org_id!==null&&(r.org_id=String(t.org_id)),t.user_id!==void 0&&t.user_id!==null&&(r.user_id=String(t.user_id)),typeof t.plan=="string"&&t.plan&&(r.plan=t.plan),typeof t.user_type=="string"&&t.user_type&&(r.user_type=t.user_type),Object.keys(r).length===0)return;let n=s(i);await o.promises.mkdir(h.dirname(n),{recursive:!0});let e=`${n}.tmp-${process.pid}`;await o.promises.writeFile(e,JSON.stringify(r),{mode:384}),await o.promises.rename(e,n)}function M(i){try{o.rmSync(s(i),{force:!0})}catch{}}export{u as a,k as b,A as c,M as d};
@@ -0,0 +1,7 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a as x}from"./chunk-TDPWFYTJ.js";import{b as A}from"./chunk-PCL2FYPE.js";import{d as R}from"./chunk-QWEQ742S.js";import{a as S}from"./chunk-MMBBQ4OZ.js";import{a as E}from"./chunk-TD6GCEIK.js";import{b as T}from"./chunk-UV7FPIBL.js";import{a as m}from"./chunk-V24LUINK.js";import{d as _}from"./chunk-BRWCWZE3.js";import{f as y}from"./chunk-A7RJQJNT.js";import{spawn as U,execSync as L}from"child_process";import{appendFileSync as C,existsSync as f,mkdirSync as I}from"fs";import{homedir as V}from"os";import{join as k,resolve as s,dirname as v,delimiter as h}from"path";import{fileURLToPath as D}from"url";import{createInterface as P}from"readline";async function*N(e){let n=P({input:e,crlfDelay:1/0});for await(let r of n){let o=r.trim();if(o)try{let i=JSON.parse(o);i&&typeof i.type=="string"&&(yield i)}catch{}}}function w(e){return e==="action"?{set:{V16_AGENT_ENABLE_ALL_BLOCKERS:"true",V16_BIFURCATION_PHASES:"1"},unset:["V16_NETWORK_WS","V16_NETWORK_SSE"]}:{set:{V16_BIFURCATION_PHASES:"1"},unset:["V16_AGENT_ENABLE_ALL_BLOCKERS","V16_NETWORK_WS","V16_NETWORK_SSE"]}}function O(e){return e?{set:{},unset:["V16_AGENT_SKIP_CP_FINAL"]}:{set:{V16_AGENT_SKIP_CP_FINAL:"true"},unset:[]}}function b(e){return e==="dom"?{set:{V16_AGENT_ENABLE_TEXTUAL_VISUAL:"true"},unset:[]}:{set:{},unset:["V16_AGENT_ENABLE_TEXTUAL_VISUAL"]}}var c=v(D(import.meta.url));function B(){for(let e of["python3","python"])try{return L(`${e} --version`,{stdio:"ignore"}),e}catch{}return null}function H(){let n=process.platform==="win32"?"v16-runner.exe":"v16-runner",r={"darwin-arm64":["@testmuai/kane-cli-darwin-arm64","@lambdatestincprivate/kane-cli-darwin-arm64"],"darwin-x64":["@testmuai/kane-cli-darwin-x64","@lambdatestincprivate/kane-cli-darwin-x64"],"linux-x64":["@testmuai/kane-cli-linux-x64","@lambdatestincprivate/kane-cli-linux-x64"],"linux-arm64":["@testmuai/kane-cli-linux-arm64","@lambdatestincprivate/kane-cli-linux-arm64"],"win32-x64":["@testmuai/kane-cli-win-x64","@lambdatestincprivate/kane-cli-win-x64"]},o=`${process.platform}-${process.arch}`,i=r[o];if(i)for(let t of i){let a=[s(c,"..","node_modules",t,"bin",n),s(c,"..","..","node_modules",t,"bin",n),s(c,"..","..","..","node_modules",t,"bin",n),s(c,"..","..","..","..","node_modules",t,"bin",n)];for(let u of a)if(f(u))return{cmd:u,args:[]}}let d=[s(c,"bin",n),s(c,"..","bin",n),s(c,"..","..","..","..","v16-runner","dist",n),s(c,"..","..","..","v16-runner","dist",n),s(c,"..","..","v16-runner","dist",n),s(process.cwd(),"v16-runner","dist",n),s(process.cwd(),"..","v16-runner","dist",n)];for(let t of d)if(f(t))return{cmd:t,args:[]};let l=[s(c,"..","..","v16-runner"),s(c,"..","..","..","..","v16-runner"),s(c,"..","..","..","v16-runner"),s(process.cwd(),"v16-runner"),s(process.cwd(),"..","v16-runner")];for(let t of l)if(f(s(t,"main.py"))){for(let u of[s(t,".venv","bin","python"),s(t,"..",".venv","bin","python"),s(t,"..","browser-agent",".venv","bin","python")])if(f(u))return{cmd:u,args:["main.py"],cwd:t};let a=B();if(a)return{cmd:a,args:["main.py"],cwd:t}}return null}function M(e){return e?k(V(),".testmuai","kaneai","sessions",e,"runner-stderr.log"):null}function K(e){let n=U(e.runner.cmd,e.runner.args,{stdio:["pipe","pipe","pipe"],env:e.env,cwd:e.runner.cwd});n.stdin.on("error",()=>{});let r=M(e.sessionId);if(r)try{I(v(r),{recursive:!0})}catch{}let o=1e5,i="";n.stderr.on("data",u=>{if(i+=u.toString(),i.length>o&&(i=i.slice(-o)),r)try{C(r,u)}catch{}}),n.on("error",u=>{e.log?.("error","RUNNER_SPAWN_ERROR","Runner spawn error",{error:u.message})});let d=null,l=null,t=new Promise(u=>{n.on("close",(p,g)=>{d=p,l=g?String(g):null,e.log?.("info","RUNNER_EXIT","Runner exited",{code:p,signal:l??"none"}),u({code:p,signal:l})})}),a=N(n.stdout);return{child:n,events:a,getStderr:()=>i,getExitCode:()=>d,getExitSignal:()=>l,exited:t}}async function G(e,n){if(!n?.platform||!n.target)return;if(y(n.target)){e.TESTMU_RUN_TARGET??="cloud",e.LT_HUB_URL??=m(e.TESTMUAI_ENV==="stage"?"stage":"prod").mobileHubUrl;return}let r=await R(n.platform)?.toolEnv(n.target)??{dirs:[]};if(r.dirs.length>0&&(e.PATH=[...r.dirs,e.PATH??""].filter(Boolean).join(h)),r.appiumHome&&(e.APPIUM_HOME=r.appiumHome),r.wdaRoot&&(e.TESTMU_IOS_WDA_DERIVED_DATA=r.wdaRoot),n.platform==="android"){let o=S();o&&(e.PATH=[o.platformToolsDir,e.PATH??""].filter(Boolean).join(h),e.ANDROID_HOME=o.root,e.ANDROID_SDK_ROOT=o.root)}}function j(e){let n={...process.env,...E(process.env)};e.environment&&(n.TESTMUAI_ENV=e.environment),n.TESTMUAI_SOURCE="kane-cli",process.platform==="win32"&&(n.PYTHONIOENCODING="utf-8",n.PYTHONUTF8="1");let r=m(e.environment);n.V16_SERVER_API_HOST=r.v16ServerHost,n.ATMS_URL=r.tmsBaseUrl.replace(/\/api\/?$/,""),e.username&&e.accessKey&&(n.LT_USERNAME=e.username,n.LT_ACCESS_KEY=e.accessKey),e.sessionId&&(n.TESTMUAI_SESSION_ID=e.sessionId);let o=w(e.mode??"testing");Object.assign(n,o.set);for(let a of o.unset)delete n[a];let i=new A().load(),d=b(e.assertionMode??(i.assertion_mode==="visual"?"visual":"dom"));Object.assign(n,d.set);for(let a of d.unset)delete n[a];let l=e.finalValidation??i.final_validation,t=O(l);Object.assign(n,t.set);for(let a of t.unset)delete n[a];return n}function W(e,n){let r=m(n?.environment),o=x();o!==void 0&&e.ap_mode===void 0&&(e.ap_mode=o),e.telemetry_proxy_url===void 0&&(e.telemetry_proxy_url=T()),e.media_upload===void 0&&e.org_id&&e.username&&e.access_key&&(e.media_upload=$(r,e.org_id))}function $(e,n){return{url:e.shareApiBaseUrl.replace(/\/$/,"")+"/mfs/v1.0/media/upload",artefacts_host:e.mediaArtefactsHost,org_id:n,media_dir:_,files_url:e.tmsBaseUrl.replace(/\/api\/?$/,"")}}async function ce(e,n){let r=H();if(!r)throw new Error("v16-runner not found. Build the binary with `cd v16-runner && python build.py` or ensure Python is available.");process.env.KANE_SPAWN_DEBUG&&process.stderr.write(`[spawn-debug] ${JSON.stringify(r)}
3
+ `);let o=j({environment:n?.environment,mode:n?.mode,assertionMode:n?.assertionMode,finalValidation:n?.finalValidation,username:e.username,accessKey:e.access_key,sessionId:e.session_id});e.device?.platform&&await G(o,e.device),W(e,{environment:n?.environment});let i=K({env:o,runner:r,log:n?.log,sessionId:e.session_id}),d=i.child;d.stdin.write(JSON.stringify(e)+`
4
+ `);let l=M(e.session_id);if(l)try{I(v(l),{recursive:!0}),C(l,`--- runner spawn ${new Date().toISOString()} run_index=${e.run_index} ---
5
+ `)}catch{}return{child:d,events:i.events,sendUserResponse(t){let a=JSON.stringify({type:"user_response",answer:t});try{d.stdin.write(a+`
6
+ `)}catch{}},sendCancel(t){let a=JSON.stringify({type:"cancel",reason:t});try{d.stdin.write(a+`
7
+ `)}catch{}},cancel(){d.kill("SIGTERM")},get stderr(){return i.getStderr()},get exitCode(){return i.getExitCode()},get exitSignal(){return i.getExitSignal()},exited:i.exited}}export{H as a,K as b,G as c,j as d,W as e,$ as f,ce as g};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as j}from"./chunk-MUX2A37P.js";import{b as g,d as C,e as q,f as I}from"./chunk-W5HFUBXD.js";import{a as V}from"./chunk-EZMRWXRT.js";import{B as k,F as S,M as R,ea as h,fa as P,v as b}from"./chunk-PI7OXS62.js";import{o as v}from"./chunk-HYJVYYAZ.js";function M(t,e,s,p=g()){return{store:t,rootSid:e,locks:t.locks(e),probe:s??j(t,{...p.calls(()=>({})),readVector:(i,u,n)=>C(t,i,u,n),writeVector:(i,u,n,r)=>q(t,i,u,n,r),prefetchVectors:(i,u,n)=>I(t,i,u,n)})}}var O=new WeakMap;function B(t){let e=O.get(t);return e||O.set(t,e=g()),e}var Y=new Set(["archive"]);async function U(t,e,s,p){let i=R(t.store);if(s.v==="defer")return{outcome:"deferred"};if(e.kind==="MODIFY_HELD"){if(!e.heldPayload)return{outcome:"failed",detail:`${e.ref} carries no held payload`};let r=e.heldPayload;if(s.v==="keep_current"){if(!r.event_id)return{outcome:"failed",detail:v().text("note.held_no_event_id",{sid:r.sid})};let{commitChatTurn:o}=await import("./chat-committer-ZKEKJA2R.js"),m=o({store:t.store,graph:i,ops:[{kind:"resolve_question",questionId:`drop-held:${r.sid}:${r.tempRef}`,resolution:"deferred",eventId:r.event_id}],by:p});return m.errors?{outcome:"failed",detail:m.errors.map(d=>`${d.code}: ${d.detail}`).join("; ")}:(t.signals?.({ref:e.ref,verdict:"held-dropped"}),{outcome:"committed",detail:"held payload dropped (recorded) \u2014 the owner's resume will not re-present it"})}if(s.v==="approve"){let o=r.content._held??null;if(!o?.source_id||!o.source_cid||!o.anchor||!o.quote)return{outcome:"failed",detail:v().text("note.held_no_provenance",{sid:r.sid})};{let a=i.mediaOf(o.source_cid),f=b(t.store,i,o.source_cid),w=a.format==="image"?null:f?k(f):null;if(a.format!=="image"&&w===null)return{outcome:"failed",detail:v().text("note.held_no_citable_text",{sid:r.sid,source_id:o.source_id,source_cid:o.source_cid})};let $=S(a,{anchor:o.anchor,quote:o.quote},w);if($.length>0)return{outcome:"failed",detail:v().text("note.held_unverified",{sid:r.sid,errors:$.map(y=>`${y.code}: ${y.detail}`).join("; ")})}}let{commitProposal:m}=await import("./committer-UO3B3S5Y.js"),{_held:d,...c}=r.content,D={version:1,read_basis:i.latestHash,source:{source_id:o.source_id,source_cid:o.source_cid},use_cases:[{temp_ref:r.tempRef,title:String(c.title??r.tempRef),...c.summary!==void 0?{summary:c.summary}:{},risk:String(c.risk??"med"),cite:{anchor:o.anchor,quote:o.quote},depends_on_hint:[],matches_existing:null}]},l=await V(M(t.store,t.rootSid??`review-${process.pid}`,void 0,B(t)),{verb:"maintain",ucTargets:[],newBuCandidates:[{tempRef:r.tempRef,title:String(c.title??r.tempRef),probeText:`${String(c.title??"")} ${String(c.summary??"")}`.trim()}],sourcePins:[{source_id:o.source_id,source_cid:o.source_cid}],readBasis:i.latestHash,...r.event_id?{eventIds:[r.event_id]}:{}},a=>{let f=m({store:t.store,graph:a.graph,scope:a.scope,proposal:D,proposalId:null,verdicts:new Map([[r.tempRef,{resolution:"skipped"}]]),by:p,autoName:!0,allowStaleBasis:!0,eventIds:r.event_id?[r.event_id]:a.eventIds("maintain",1),sid:a.sid,probeHits:a.probeHits});return f.errors!==null?{errors:f.errors}:{result:f,record:f.record}}),_=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 _.errors?{outcome:"failed",detail:_.errors.map(a=>`${a.code}: ${a.detail}`).join("; ")}:(t.signals?.({ref:e.ref,verdict:"held-applied"}),{outcome:"committed",detail:`held payload committed (derived) by ${p.id}`})}return{outcome:"failed",detail:`verdict ${s.v} does not apply to a MODIFY_HELD card`}}let u=i.resolve(e.ref);if(!u)return{outcome:"failed",detail:`${e.ref} names nothing in the graph`};let n=i.tipOf(u.cid);if(s.v==="archive"){if(!s.because||!s.because.trim())return{outcome:"failed",detail:"archive requires --because (a reason the record keeps)"};let r=h({store:t.store,graph:i,verdicts:new Map([[n,{resolution:"rejected",reason:s.because}]]),by:p});return r.errors?{outcome:"failed",detail:r.errors.map(o=>`${o.code}: ${o.detail}`).join("; ")}:(t.signals?.({ref:e.ref,verdict:"archived",reason:s.because}),{outcome:"retired"})}if(s.v==="approve"){let r=h({store:t.store,graph:i,verdicts:new Map([[n,{resolution:"approved"}]]),by:p});return r.errors?{outcome:"failed",detail:r.errors.map(o=>`${o.code}: ${o.detail}`).join("; ")}:(t.signals?.({ref:e.ref,verdict:"approved"}),{outcome:"applied"})}if(s.v==="merge"||s.v==="keep_both"){if(e.kind!=="PAIR"||!e.pair)return{outcome:"failed",detail:`${e.ref} is not a PAIR card`};let r=i.resolve(e.pair.candidate_cid);if(!r)return{outcome:"failed",detail:`pair candidate ${e.pair.candidate_ref} names nothing`};let o=i.tipOf(r.cid);if(s.v==="merge"){let d=P({store:t.store,graph:i,survivor:o,merged:n,reason:`pair merge: duplicate of ${e.pair.candidate_ref} (score ${e.pair.score})`,by:p});return d.errors?{outcome:"failed",detail:d.errors.map(c=>`${c.code}: ${c.detail}`).join("; ")}:(t.signals?.({ref:e.ref,verdict:"pair-merged",reason:e.pair.candidate_ref}),{outcome:"committed",detail:`merged into ${e.pair.candidate_ref} \u2014 survivor stays derived`})}let m=h({store:t.store,graph:i,verdicts:new Map([[n,{resolution:"approved"}],[o,{resolution:"approved"}]]),by:p});return m.errors?{outcome:"failed",detail:m.errors.map(d=>`${d.code}: ${d.detail}`).join("; ")}:(t.signals?.({ref:e.ref,verdict:"pair-kept-both",reason:e.pair.candidate_ref}),{outcome:"applied",detail:"both promoted as distinct"})}return{outcome:"failed",detail:`verdict ${s.v} does not apply to a ${e.kind} card`}}export{M as a,B as b,Y as c,U as d};
2
+ import{a as j}from"./chunk-MUX2A37P.js";import{b as g,d as C,e as q,f as I}from"./chunk-W5HFUBXD.js";import{a as V}from"./chunk-OVB5GVRB.js";import{B as k,F as S,M as R,ea as h,fa as P,v as b}from"./chunk-5EAJO372.js";import{o as v}from"./chunk-HYJVYYAZ.js";function M(t,e,s,p=g()){return{store:t,rootSid:e,locks:t.locks(e),probe:s??j(t,{...p.calls(()=>({})),readVector:(i,u,n)=>C(t,i,u,n),writeVector:(i,u,n,r)=>q(t,i,u,n,r),prefetchVectors:(i,u,n)=>I(t,i,u,n)})}}var O=new WeakMap;function B(t){let e=O.get(t);return e||O.set(t,e=g()),e}var Y=new Set(["archive"]);async function U(t,e,s,p){let i=R(t.store);if(s.v==="defer")return{outcome:"deferred"};if(e.kind==="MODIFY_HELD"){if(!e.heldPayload)return{outcome:"failed",detail:`${e.ref} carries no held payload`};let r=e.heldPayload;if(s.v==="keep_current"){if(!r.event_id)return{outcome:"failed",detail:v().text("note.held_no_event_id",{sid:r.sid})};let{commitChatTurn:o}=await import("./chat-committer-7E3TRZ6P.js"),m=o({store:t.store,graph:i,ops:[{kind:"resolve_question",questionId:`drop-held:${r.sid}:${r.tempRef}`,resolution:"deferred",eventId:r.event_id}],by:p});return m.errors?{outcome:"failed",detail:m.errors.map(d=>`${d.code}: ${d.detail}`).join("; ")}:(t.signals?.({ref:e.ref,verdict:"held-dropped"}),{outcome:"committed",detail:"held payload dropped (recorded) \u2014 the owner's resume will not re-present it"})}if(s.v==="approve"){let o=r.content._held??null;if(!o?.source_id||!o.source_cid||!o.anchor||!o.quote)return{outcome:"failed",detail:v().text("note.held_no_provenance",{sid:r.sid})};{let a=i.mediaOf(o.source_cid),f=b(t.store,i,o.source_cid),w=a.format==="image"?null:f?k(f):null;if(a.format!=="image"&&w===null)return{outcome:"failed",detail:v().text("note.held_no_citable_text",{sid:r.sid,source_id:o.source_id,source_cid:o.source_cid})};let $=S(a,{anchor:o.anchor,quote:o.quote},w);if($.length>0)return{outcome:"failed",detail:v().text("note.held_unverified",{sid:r.sid,errors:$.map(y=>`${y.code}: ${y.detail}`).join("; ")})}}let{commitProposal:m}=await import("./committer-L2HXEODA.js"),{_held:d,...c}=r.content,D={version:1,read_basis:i.latestHash,source:{source_id:o.source_id,source_cid:o.source_cid},use_cases:[{temp_ref:r.tempRef,title:String(c.title??r.tempRef),...c.summary!==void 0?{summary:c.summary}:{},risk:String(c.risk??"med"),cite:{anchor:o.anchor,quote:o.quote},depends_on_hint:[],matches_existing:null}]},l=await V(M(t.store,t.rootSid??`review-${process.pid}`,void 0,B(t)),{verb:"maintain",ucTargets:[],newBuCandidates:[{tempRef:r.tempRef,title:String(c.title??r.tempRef),probeText:`${String(c.title??"")} ${String(c.summary??"")}`.trim()}],sourcePins:[{source_id:o.source_id,source_cid:o.source_cid}],readBasis:i.latestHash,...r.event_id?{eventIds:[r.event_id]}:{}},a=>{let f=m({store:t.store,graph:a.graph,scope:a.scope,proposal:D,proposalId:null,verdicts:new Map([[r.tempRef,{resolution:"skipped"}]]),by:p,autoName:!0,allowStaleBasis:!0,eventIds:r.event_id?[r.event_id]:a.eventIds("maintain",1),sid:a.sid,probeHits:a.probeHits});return f.errors!==null?{errors:f.errors}:{result:f,record:f.record}}),_=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 _.errors?{outcome:"failed",detail:_.errors.map(a=>`${a.code}: ${a.detail}`).join("; ")}:(t.signals?.({ref:e.ref,verdict:"held-applied"}),{outcome:"committed",detail:`held payload committed (derived) by ${p.id}`})}return{outcome:"failed",detail:`verdict ${s.v} does not apply to a MODIFY_HELD card`}}let u=i.resolve(e.ref);if(!u)return{outcome:"failed",detail:`${e.ref} names nothing in the graph`};let n=i.tipOf(u.cid);if(s.v==="archive"){if(!s.because||!s.because.trim())return{outcome:"failed",detail:"archive requires --because (a reason the record keeps)"};let r=h({store:t.store,graph:i,verdicts:new Map([[n,{resolution:"rejected",reason:s.because}]]),by:p});return r.errors?{outcome:"failed",detail:r.errors.map(o=>`${o.code}: ${o.detail}`).join("; ")}:(t.signals?.({ref:e.ref,verdict:"archived",reason:s.because}),{outcome:"retired"})}if(s.v==="approve"){let r=h({store:t.store,graph:i,verdicts:new Map([[n,{resolution:"approved"}]]),by:p});return r.errors?{outcome:"failed",detail:r.errors.map(o=>`${o.code}: ${o.detail}`).join("; ")}:(t.signals?.({ref:e.ref,verdict:"approved"}),{outcome:"applied"})}if(s.v==="merge"||s.v==="keep_both"){if(e.kind!=="PAIR"||!e.pair)return{outcome:"failed",detail:`${e.ref} is not a PAIR card`};let r=i.resolve(e.pair.candidate_cid);if(!r)return{outcome:"failed",detail:`pair candidate ${e.pair.candidate_ref} names nothing`};let o=i.tipOf(r.cid);if(s.v==="merge"){let d=P({store:t.store,graph:i,survivor:o,merged:n,reason:`pair merge: duplicate of ${e.pair.candidate_ref} (score ${e.pair.score})`,by:p});return d.errors?{outcome:"failed",detail:d.errors.map(c=>`${c.code}: ${c.detail}`).join("; ")}:(t.signals?.({ref:e.ref,verdict:"pair-merged",reason:e.pair.candidate_ref}),{outcome:"committed",detail:`merged into ${e.pair.candidate_ref} \u2014 survivor stays derived`})}let m=h({store:t.store,graph:i,verdicts:new Map([[n,{resolution:"approved"}],[o,{resolution:"approved"}]]),by:p});return m.errors?{outcome:"failed",detail:m.errors.map(d=>`${d.code}: ${d.detail}`).join("; ")}:(t.signals?.({ref:e.ref,verdict:"pair-kept-both",reason:e.pair.candidate_ref}),{outcome:"applied",detail:"both promoted as distinct"})}return{outcome:"failed",detail:`verdict ${s.v} does not apply to a ${e.kind} card`}}export{M as a,B as b,Y as c,U as d};
@@ -1,9 +1,9 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{d as V,e as P,f as Ve,k as He}from"./chunk-7SU53QGU.js";import{b as Pe}from"./chunk-6HRNG4CK.js";import{j as Oe,k as X}from"./chunk-4CJQ7XZP.js";import{h as Y}from"./chunk-3RO2YGKH.js";import{e as Re}from"./chunk-NI3TIAD7.js";import{e as ge,i as he}from"./chunk-XMPTFXPW.js";import{a as ee,b as Se,c as _e}from"./chunk-32HED7X2.js";import{a as Me,b as Ue,c as De,d as te,g as Ce,m as ne,n as G,o as Ae,p as se,q as Be,r as je,s as re,t as Fe,u as Ge}from"./chunk-X2MDL6S4.js";import{e as Te}from"./chunk-LRNUGKYH.js";import{c as Ne,h as Ee}from"./chunk-ZDCXWEQG.js";import{j as Le,k as $e}from"./chunk-L3BUPFAQ.js";import{f as xe,g as q,j as Z,n as ve}from"./chunk-Z24SD2EJ.js";import{j as ke}from"./chunk-REKHAN53.js";import{b as F}from"./chunk-CQDCNP7V.js";import{b as Q}from"./chunk-EBJW6POT.js";import{B as we,Ha as m,f as pe,p as Ie,w as be}from"./chunk-WE7HRAGO.js";import{a as E,e as ye}from"./chunk-4C7WVQOD.js";import{j as J}from"./chunk-PI7OXS62.js";import{d as j}from"./chunk-DBMW3VUN.js";import{a as me}from"./chunk-FOJHSG5M.js";import{existsSync as oe,readFileSync as ae,statSync as H}from"fs";import{basename as de,extname as K}from"path";var ie=1024*1024,qe=1e3,Ze=e=>12e4+Math.ceil(e/ie)*1e3,v=e=>e>=ie?`${(e/ie).toFixed(1).replace(/\.0$/,"")} MB`:`${Math.max(1,Math.round(e/1024))} KB`,et=e=>new Promise(i=>setTimeout(i,e)),tt=e=>/^[a-z][a-z0-9+.-]*:/i.test(e)&&!oe(e);async function Ke(e,i,s,l){let o=new Map(l.map(a=>[a.sourceId,a.head])),d=[];for(let a of s){let r=o.get(a.sourceId);(r?await e.mainNode(i,r).then(f=>f.content.blob,()=>null):null)!==F(a.bytes)&&d.push(a)}return d}var nt=new Set(["KIND_MISMATCH","SITE_MOVED","UUID_MOVED","WEB_URL_CHANGED"]);function T(e){let i=e.code==="PLUGIN_HOOK_FAILED"||e.code==="PLUGIN_HOOK_TIMEOUT";return{refusal:{code:e.code,message:e.message,remedy:e.remedy??"check the source, then run the command again",...i?{support:!0}:{}},exit:i?1:2}}async function st(e,i,s){let l=i.plugin.manifest.id,o=ee(e),d;try{d=await _e(i.plugin,"claim",j.hookMs,()=>i.plugin.claim({ref:i.ref,named:i.named,isFile:o}))}catch(t){if(t instanceof Ne)return T(t.refusal);throw t}if(d==null)return T({code:"PLUGIN_NOT_CLAIMED",message:`plugin ${l} does not read ${i.ref}`,remedy:i.named?`drop the ${l}: prefix, or name the plugin that reads it`:"ingest it as a file of a built-in kind"});let a=d.sourceId;if(typeof a!="string")return T({code:"PLUGIN_HOOK_FAILED",message:`plugin ${l} answered claim with something that is not a claim`});let r=s??a;if(!Se(r))return T({code:"PLUGIN_SOURCE_ID_INVALID",message:`${JSON.stringify(r)} is not an id a source may have: it starts with a letter or digit and holds letters, digits and . _ -, at most 128 characters`,remedy:s===void 0?"give the source an id with --as <id>":"give another id with --as <id>"});let y={id:l,ref:i.ref,named:i.named,isFile:o},f=v(j.contentBytes);if(!o)return{item:{kind:"file",path:e,node:`ref:${e}`,file:e,bytes:Buffer.alloc(0),sourceId:r,limit:f,plugin:y}};let I=de(e),c;try{c=ae(e)}catch{return{refusal:m.ingestCantOpen(I),exit:2}}if(c.byteLength>j.contentBytes)return{refusal:m.ingestTooLarge(I,v(c.byteLength),f),exit:2};let{dev:u,ino:p}=H(e);return{item:{kind:"file",path:e,node:`${u}:${p}`,file:I,bytes:c,sourceId:r,limit:f,plugin:y}}}var S=e=>e.kind==="file"?e.path:e.address;function We(e){if(e.provider.name==="web")return`web|${e.sourceId}`;let i=new URL(e.address),s=e.provider.name.startsWith("linear")?`${i.host}/${i.pathname.split("/")[1]??""}`:i.host;return`${e.provider.name}|${s.toLowerCase()}|${e.sourceId}`}var rt=(e,i)=>e.kind==="file"?i.kind==="file"&&e.node===i.node:i.kind==="link"&&We(e)===We(i);async function it(e,i,s){let l=new Map;for(let t of e)l.set(t.sourceId,[...l.get(t.sourceId)??[],t]);let o=[...l.values()].filter(t=>t.length>1);if(o.length===0)return null;let d=i?.map(t=>t.sourceId)??null,a=new Set(o.flatMap(t=>t.slice(1))),r=new Set([...l.keys(),...d??[]]),y=t=>{if(d===null)return null;let R=2;for(;r.has(`${t}-${R}`);)R++;return r.add(`${t}-${R}`),`${t}-${R}`},f=t=>t.kind==="file"?t.path:te(t.provider.name,t.address),I=new Set(i?.filter(t=>t.head!==null).map(t=>t.sourceId)),c=e.filter(t=>!a.has(t)&&I.has(t.sourceId)),u=await s(c.flatMap(t=>t.kind==="file"?[t]:[])),p=e.filter(t=>!a.has(t)&&!u.includes(t));return je(o.map(t=>({names:t.map(f),id:t[0].sourceId})),p.map(S),e.filter(t=>a.has(t)).map(t=>({ref:S(t),as:y(t.sourceId),place:l.get(t.sourceId).indexOf(t)+1})),{reviews:u.flatMap(t=>t.kind==="file"?[{name:t.file,ref:t.path,id:t.sourceId}]:[]),link:c.some(t=>t.kind==="link"),firstTwin:p.some(t=>l.get(t.sourceId).length>1)})}async function Ft(e){try{return await ot(e)}finally{await be()}}async function ot(e){let i=e.mode==="agent",s=n=>i?ke(ge("ndjson",n,e.testing?.agentLines?{stdout:e.testing.agentLines,stderr:()=>{}}:void 0),{atQuestionsOnly:!0}):null,l=s("extract");l&&e.choice.onboarded&&l.event({type:"folder_linked",project_id:e.choice.projectId,project:e.choice.projectName});let o=(n,h,g=!1,O=l)=>O?(O.event({type:"error",code:n.code,message:n.message,...we(n),...n.notAdded?{not_added:n.notAdded}:{}}),O.done(h,"refused")):(g&&e.choice.onboarded?process.stdout.write(`${Oe(e.choice.projectName)}
2
+ import{d as V,e as P,f as Ve,k as He}from"./chunk-NZ7UCAN6.js";import{b as Pe}from"./chunk-PKXWYYVK.js";import{j as Oe,k as X}from"./chunk-AXOSLGQ4.js";import{e as Re}from"./chunk-IT6M7OMG.js";import{h as Y}from"./chunk-RM5ZVDVR.js";import{e as ge,i as he}from"./chunk-XMPTFXPW.js";import{a as Me,b as Ue,c as De,d as te,g as Ce,m as ne,n as G,o as Ae,p as se,q as Be,r as je,s as re,t as Fe,u as Ge}from"./chunk-CVVUBCB7.js";import{e as Te}from"./chunk-77BZTEHJ.js";import{a as ee,b as Se,c as _e}from"./chunk-6KUUSONE.js";import{c as Ne,h as Ee}from"./chunk-GRQKMOKE.js";import{j as Le,k as $e}from"./chunk-3CFAE36M.js";import{f as xe,g as q,j as Z,n as ve}from"./chunk-C3DMMAFP.js";import{j as ke}from"./chunk-REKHAN53.js";import{b as F}from"./chunk-5ORBAYTU.js";import{b as Q}from"./chunk-XRJH4UF3.js";import{B as we,Ha as m,f as pe,p as Ie,w as be}from"./chunk-RHQLDNZL.js";import{a as E,e as ye}from"./chunk-4C7WVQOD.js";import{j as J}from"./chunk-5EAJO372.js";import{d as j}from"./chunk-DBMW3VUN.js";import{a as me}from"./chunk-FOJHSG5M.js";import{existsSync as oe,readFileSync as ae,statSync as H}from"fs";import{basename as de,extname as K}from"path";var ie=1024*1024,qe=1e3,Ze=e=>12e4+Math.ceil(e/ie)*1e3,v=e=>e>=ie?`${(e/ie).toFixed(1).replace(/\.0$/,"")} MB`:`${Math.max(1,Math.round(e/1024))} KB`,et=e=>new Promise(i=>setTimeout(i,e)),tt=e=>/^[a-z][a-z0-9+.-]*:/i.test(e)&&!oe(e);async function Ke(e,i,s,l){let o=new Map(l.map(a=>[a.sourceId,a.head])),d=[];for(let a of s){let r=o.get(a.sourceId);(r?await e.mainNode(i,r).then(f=>f.content.blob,()=>null):null)!==F(a.bytes)&&d.push(a)}return d}var nt=new Set(["KIND_MISMATCH","SITE_MOVED","UUID_MOVED","WEB_URL_CHANGED"]);function T(e){let i=e.code==="PLUGIN_HOOK_FAILED"||e.code==="PLUGIN_HOOK_TIMEOUT";return{refusal:{code:e.code,message:e.message,remedy:e.remedy??"check the source, then run the command again",...i?{support:!0}:{}},exit:i?1:2}}async function st(e,i,s){let l=i.plugin.manifest.id,o=ee(e),d;try{d=await _e(i.plugin,"claim",j.hookMs,()=>i.plugin.claim({ref:i.ref,named:i.named,isFile:o}))}catch(t){if(t instanceof Ne)return T(t.refusal);throw t}if(d==null)return T({code:"PLUGIN_NOT_CLAIMED",message:`plugin ${l} does not read ${i.ref}`,remedy:i.named?`drop the ${l}: prefix, or name the plugin that reads it`:"ingest it as a file of a built-in kind"});let a=d.sourceId;if(typeof a!="string")return T({code:"PLUGIN_HOOK_FAILED",message:`plugin ${l} answered claim with something that is not a claim`});let r=s??a;if(!Se(r))return T({code:"PLUGIN_SOURCE_ID_INVALID",message:`${JSON.stringify(r)} is not an id a source may have: it starts with a letter or digit and holds letters, digits and . _ -, at most 128 characters`,remedy:s===void 0?"give the source an id with --as <id>":"give another id with --as <id>"});let y={id:l,ref:i.ref,named:i.named,isFile:o},f=v(j.contentBytes);if(!o)return{item:{kind:"file",path:e,node:`ref:${e}`,file:e,bytes:Buffer.alloc(0),sourceId:r,limit:f,plugin:y}};let I=de(e),c;try{c=ae(e)}catch{return{refusal:m.ingestCantOpen(I),exit:2}}if(c.byteLength>j.contentBytes)return{refusal:m.ingestTooLarge(I,v(c.byteLength),f),exit:2};let{dev:u,ino:p}=H(e);return{item:{kind:"file",path:e,node:`${u}:${p}`,file:I,bytes:c,sourceId:r,limit:f,plugin:y}}}var S=e=>e.kind==="file"?e.path:e.address;function We(e){if(e.provider.name==="web")return`web|${e.sourceId}`;let i=new URL(e.address),s=e.provider.name.startsWith("linear")?`${i.host}/${i.pathname.split("/")[1]??""}`:i.host;return`${e.provider.name}|${s.toLowerCase()}|${e.sourceId}`}var rt=(e,i)=>e.kind==="file"?i.kind==="file"&&e.node===i.node:i.kind==="link"&&We(e)===We(i);async function it(e,i,s){let l=new Map;for(let t of e)l.set(t.sourceId,[...l.get(t.sourceId)??[],t]);let o=[...l.values()].filter(t=>t.length>1);if(o.length===0)return null;let d=i?.map(t=>t.sourceId)??null,a=new Set(o.flatMap(t=>t.slice(1))),r=new Set([...l.keys(),...d??[]]),y=t=>{if(d===null)return null;let R=2;for(;r.has(`${t}-${R}`);)R++;return r.add(`${t}-${R}`),`${t}-${R}`},f=t=>t.kind==="file"?t.path:te(t.provider.name,t.address),I=new Set(i?.filter(t=>t.head!==null).map(t=>t.sourceId)),c=e.filter(t=>!a.has(t)&&I.has(t.sourceId)),u=await s(c.flatMap(t=>t.kind==="file"?[t]:[])),p=e.filter(t=>!a.has(t)&&!u.includes(t));return je(o.map(t=>({names:t.map(f),id:t[0].sourceId})),p.map(S),e.filter(t=>a.has(t)).map(t=>({ref:S(t),as:y(t.sourceId),place:l.get(t.sourceId).indexOf(t)+1})),{reviews:u.flatMap(t=>t.kind==="file"?[{name:t.file,ref:t.path,id:t.sourceId}]:[]),link:c.some(t=>t.kind==="link"),firstTwin:p.some(t=>l.get(t.sourceId).length>1)})}async function Ft(e){try{return await ot(e)}finally{await be()}}async function ot(e){let i=e.mode==="agent",s=n=>i?ke(ge("ndjson",n,e.testing?.agentLines?{stdout:e.testing.agentLines,stderr:()=>{}}:void 0),{atQuestionsOnly:!0}):null,l=s("extract");l&&e.choice.onboarded&&l.event({type:"folder_linked",project_id:e.choice.projectId,project:e.choice.projectName});let o=(n,h,g=!1,O=l)=>O?(O.event({type:"error",code:n.code,message:n.message,...we(n),...n.notAdded?{not_added:n.notAdded}:{}}),O.done(h,"refused")):(g&&e.choice.onboarded?process.stdout.write(`${Oe(e.choice.projectName)}
3
3
  `):e.mode==="interactive"&&process.stdout.write(`
4
4
  `),X(n),process.stdout.write(`
5
- `),h),d=(n,h)=>o(n,h,!0),a=(n,h)=>h.length>0?{...n,detail:Fe(h.map(g=>g.name)),notAdded:h.map(g=>g.ref)}:n;if(e.opts.plan)return d(m.notYet("context ingest --plan"),2);if(e.opts.as!==void 0&&e.paths.length>1)return d(Be(e.paths),2);let r=[],y=n=>{r.some(h=>rt(h,n))||r.push(n)},f=q.flatMap(n=>n.extensions).join(" ");for(let n of e.paths){let h=r.map(k=>({name:k.kind==="file"?k.file:te(k.provider.name,k.address),ref:S(k)})),g=(k,Ye)=>d(a(k,h),Ye),O=Ee().route(n,ee);if(O!==null){let k=await st(n,O,e.opts.as);if("refusal"in k)return g(k.refusal,k.exit);y(k.item);continue}if(Le(n)){let k=$e(n);if(!k?.fetch)return g(se(n),2);if(e.opts.as!==void 0&&!J(e.opts.as))return g(m.ingestBadSourceId(e.opts.as),2);y({kind:"link",address:n,provider:k,sourceId:e.opts.as??k.sourceIdFor(n)??n});continue}if(tt(n))return g(se(n),2);let w=de(n),L=Z(n);if(!L.ok)return g(m.ingestUnsupported(`${w} is a file type kane can't ingest (${K(n)||"no extension"}) \u2014 supported: ${f}`),2);if(!oe(n)||!H(n).isFile())return g(m.ingestNoFile(n),2);let D;try{D=ae(n)}catch{return g(m.ingestCantOpen(w),2)}if(D.byteLength>L.media.maxBytes)return g(m.ingestTooLarge(w,v(D.byteLength),v(L.media.maxBytes)),2);if(L.media.sniff&&!L.media.sniff(D))return g(m.ingestNotItsType(w,K(n).slice(1)),2);if(e.opts.as!==void 0&&!J(e.opts.as))return g(m.ingestBadSourceId(e.opts.as),2);let fe;try{fe=e.opts.as??ve(n)}catch{return g(m.ingestNoSourceId(w),2)}let{dev:Je,ino:Qe}=H(n);y({kind:"file",path:n,node:`${Je}:${Qe}`,file:w,bytes:D,sourceId:fe,limit:v(L.media.maxBytes)})}let I=r[0],c;try{c=e.testing?.basicAuth??await Re()}catch(n){if(!(n instanceof he))throw n;return d({code:n.code,message:n.message,...n.remedy?{remedy:n.remedy}:{}},2)}let u=pe({url:e.choice.latticeUrl,basicAuth:c,...e.testing?.run?.fetch?{fetch:e.testing.run.fetch}:{}}),p=e.choice.projectId,t=null,R=null;try{t=await u.sources(p)}catch(n){n instanceof E&&(n.code==="NO_CONTEXT"||n.code==="NOT_FOUND")?t=[]:R=n}let b=await it(r,t,n=>Ke(u,p,n,t??[]));if(b)return d(b,2);if(t===null){let{exit:n,...h}=Pe(R,e.choice,null);return d(h,n)}let x=new Set(t.filter(n=>n.head!==null).map(n=>n.sourceId)),$=r.filter(n=>x.has(n.sourceId)),N=$.flatMap(n=>n.kind==="file"?[n]:[]);if(r.length>1&&N.length>0&&N.length===$.length){let n=await Ke(u,p,N,t);if(n.length>0){let h=n.map(g=>({name:g.file,ref:S(g),id:g.sourceId}));return d(re(h,r.filter(g=>!n.includes(g)).map(S),e.choice.projectName),2)}}let M=r.length===1?$[0]:void 0;if(M){let{reviewNewVersion:n}=await import("./reconcile-remote-3W6ZTO3G.js"),h=e.mode==="interactive";h&&!e.choice.onboarded&&process.stdout.write(`using project "${e.choice.projectName}", shared with your team
6
- `);let g=s("reconcile");return n({choice:e.choice,person:u,basicAuth:c,item:M,...e.opts.as!==void 0?{as:e.opts.as}:{},supported:f,mode:e.mode==="agent"?"agent":h?"interactive":"ci",io:g,refuse:(O,w=2)=>o(O,w,!1,g),projectLine:h,nothing:(O,w)=>`${h?` ${me.green("\u2714")} `:""}${O} is already in "${w}", unchanged`,...e.testing?{testing:e.testing}:{}})}let C=e.testing?.run?.retryDeadlineMs??12e4,ze=dt(e.testing?.remoteDeps),le=[],_=r.map((n,h)=>{let g=at({person:u,choice:e.choice,item:n,first:h===0,then:e.mode==="ci"?"pause":"extract",...e.opts.as!==void 0?{as:e.opts.as}:{},supported:f,retryMs:C,remoteDeps:ze,refusal:O=>a(O,_.slice(0,h).map(w=>({name:w.name??w.file,ref:w.path??w.file}))),alone:O=>re(O.map(w=>{let L=_[w].remote;return{name:_[w].name??_[w].file,ref:S(r[w]),id:r[w].sourceId,...L?{shown:Te({source:r[w].sourceId,page:Ce({...L,address:L.origin.url})})}:{}}}),r.filter((w,L)=>!O.includes(L)).map(S),e.choice.projectName),...e.testing?{testing:e.testing}:{}});return le.push(g.ended),g.step}),ce={verb:"extract",choice:e.choice,start:{kind:"new",body:{projectId:p,verb:"extract",mode:e.mode==="interactive"?"interactive":"agent",sourceId:I.sourceId}},run:{source:I.sourceId,...e.opts.force?{force:!0}:{},...e.opts.trust!==void 0?{trust:e.opts.trust}:{}}},A=e.testing?.remoteDeps?{...e.testing.run,remoteDeps:e.testing.remoteDeps}:e.testing?.run,U;if(e.mode==="interactive"){let{runInteractiveRemote:n}=await import("./interactive-remote-7ZSTI66T.js");U=await n({...ce,subject:I.kind==="link"?De(I.provider.name,I.address):I.sourceId,ingest:_,testing:{basicAuth:c,...e.testing?.check?{check:e.testing.check}:{},...A?{run:A}:{},...e.testing?.mount?{mount:e.testing.mount}:{},...e.testing?.onController?{onController:e.testing.onController}:{}}})}else U=await He({...ce,mode:"agent",basicAuth:c,io:l,check:e.testing?.check??Ve,onProgress:()=>{},ingest:_,signals:!0,onRefusal:n=>{X(n),process.stdout.write(`
5
+ `),h),d=(n,h)=>o(n,h,!0),a=(n,h)=>h.length>0?{...n,detail:Fe(h.map(g=>g.name)),notAdded:h.map(g=>g.ref)}:n;if(e.opts.plan)return d(m.notYet("context ingest --plan"),2);if(e.opts.as!==void 0&&e.paths.length>1)return d(Be(e.paths),2);let r=[],y=n=>{r.some(h=>rt(h,n))||r.push(n)},f=q.flatMap(n=>n.extensions).join(" ");for(let n of e.paths){let h=r.map(k=>({name:k.kind==="file"?k.file:te(k.provider.name,k.address),ref:S(k)})),g=(k,Ye)=>d(a(k,h),Ye),O=Ee().route(n,ee);if(O!==null){let k=await st(n,O,e.opts.as);if("refusal"in k)return g(k.refusal,k.exit);y(k.item);continue}if(Le(n)){let k=$e(n);if(!k?.fetch)return g(se(n),2);if(e.opts.as!==void 0&&!J(e.opts.as))return g(m.ingestBadSourceId(e.opts.as),2);y({kind:"link",address:n,provider:k,sourceId:e.opts.as??k.sourceIdFor(n)??n});continue}if(tt(n))return g(se(n),2);let w=de(n),L=Z(n);if(!L.ok)return g(m.ingestUnsupported(`${w} is a file type kane can't ingest (${K(n)||"no extension"}) \u2014 supported: ${f}`),2);if(!oe(n)||!H(n).isFile())return g(m.ingestNoFile(n),2);let D;try{D=ae(n)}catch{return g(m.ingestCantOpen(w),2)}if(D.byteLength>L.media.maxBytes)return g(m.ingestTooLarge(w,v(D.byteLength),v(L.media.maxBytes)),2);if(L.media.sniff&&!L.media.sniff(D))return g(m.ingestNotItsType(w,K(n).slice(1)),2);if(e.opts.as!==void 0&&!J(e.opts.as))return g(m.ingestBadSourceId(e.opts.as),2);let fe;try{fe=e.opts.as??ve(n)}catch{return g(m.ingestNoSourceId(w),2)}let{dev:Je,ino:Qe}=H(n);y({kind:"file",path:n,node:`${Je}:${Qe}`,file:w,bytes:D,sourceId:fe,limit:v(L.media.maxBytes)})}let I=r[0],c;try{c=e.testing?.basicAuth??await Re()}catch(n){if(!(n instanceof he))throw n;return d({code:n.code,message:n.message,...n.remedy?{remedy:n.remedy}:{}},2)}let u=pe({url:e.choice.latticeUrl,basicAuth:c,...e.testing?.run?.fetch?{fetch:e.testing.run.fetch}:{}}),p=e.choice.projectId,t=null,R=null;try{t=await u.sources(p)}catch(n){n instanceof E&&(n.code==="NO_CONTEXT"||n.code==="NOT_FOUND")?t=[]:R=n}let b=await it(r,t,n=>Ke(u,p,n,t??[]));if(b)return d(b,2);if(t===null){let{exit:n,...h}=Pe(R,e.choice,null);return d(h,n)}let x=new Set(t.filter(n=>n.head!==null).map(n=>n.sourceId)),$=r.filter(n=>x.has(n.sourceId)),N=$.flatMap(n=>n.kind==="file"?[n]:[]);if(r.length>1&&N.length>0&&N.length===$.length){let n=await Ke(u,p,N,t);if(n.length>0){let h=n.map(g=>({name:g.file,ref:S(g),id:g.sourceId}));return d(re(h,r.filter(g=>!n.includes(g)).map(S),e.choice.projectName),2)}}let M=r.length===1?$[0]:void 0;if(M){let{reviewNewVersion:n}=await import("./reconcile-remote-JMV26DLX.js"),h=e.mode==="interactive";h&&!e.choice.onboarded&&process.stdout.write(`using project "${e.choice.projectName}", shared with your team
6
+ `);let g=s("reconcile");return n({choice:e.choice,person:u,basicAuth:c,item:M,...e.opts.as!==void 0?{as:e.opts.as}:{},supported:f,mode:e.mode==="agent"?"agent":h?"interactive":"ci",io:g,refuse:(O,w=2)=>o(O,w,!1,g),projectLine:h,nothing:(O,w)=>`${h?` ${me.green("\u2714")} `:""}${O} is already in "${w}", unchanged`,...e.testing?{testing:e.testing}:{}})}let C=e.testing?.run?.retryDeadlineMs??12e4,ze=dt(e.testing?.remoteDeps),le=[],_=r.map((n,h)=>{let g=at({person:u,choice:e.choice,item:n,first:h===0,then:e.mode==="ci"?"pause":"extract",...e.opts.as!==void 0?{as:e.opts.as}:{},supported:f,retryMs:C,remoteDeps:ze,refusal:O=>a(O,_.slice(0,h).map(w=>({name:w.name??w.file,ref:w.path??w.file}))),alone:O=>re(O.map(w=>{let L=_[w].remote;return{name:_[w].name??_[w].file,ref:S(r[w]),id:r[w].sourceId,...L?{shown:Te({source:r[w].sourceId,page:Ce({...L,address:L.origin.url})})}:{}}}),r.filter((w,L)=>!O.includes(L)).map(S),e.choice.projectName),...e.testing?{testing:e.testing}:{}});return le.push(g.ended),g.step}),ce={verb:"extract",choice:e.choice,start:{kind:"new",body:{projectId:p,verb:"extract",mode:e.mode==="interactive"?"interactive":"agent",sourceId:I.sourceId}},run:{source:I.sourceId,...e.opts.force?{force:!0}:{},...e.opts.trust!==void 0?{trust:e.opts.trust}:{}}},A=e.testing?.remoteDeps?{...e.testing.run,remoteDeps:e.testing.remoteDeps}:e.testing?.run,U;if(e.mode==="interactive"){let{runInteractiveRemote:n}=await import("./interactive-remote-SGM76D6M.js");U=await n({...ce,subject:I.kind==="link"?De(I.provider.name,I.address):I.sourceId,ingest:_,testing:{basicAuth:c,...e.testing?.check?{check:e.testing.check}:{},...A?{run:A}:{},...e.testing?.mount?{mount:e.testing.mount}:{},...e.testing?.onController?{onController:e.testing.onController}:{}}})}else U=await He({...ce,mode:"agent",basicAuth:c,io:l,check:e.testing?.check??Ve,onProgress:()=>{},ingest:_,signals:!0,onRefusal:n=>{X(n),process.stdout.write(`
7
7
  `)},...A?{testing:A}:{}});let W=le.map(n=>n()),B=[...W].reverse().find(n=>n.sid!==null)?.sid??null,ue=W.flatMap(n=>n.added!==null?[{name:n.name,status:n.added}]:[]),z=W.find(n=>n.refused!==null)?.refused??null;if(z!==null)return o(z.refusal,z.exit);if(e.mode==="ci"&&ue.length>0&&B!==null){let n=ue.map(({name:h,status:g})=>g==="unchanged"?`${h} is already in "${e.choice.projectName}", unchanged`:g==="versioned"?`added a new version of ${h} to session ${B}, not saved yet`:`added ${h} to session ${B}, not saved yet`);return process.stdout.write(`${n.join(`
8
8
  `)}
9
9
  extract: kane-cli context extract --resume ${B}
@@ -0,0 +1,13 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a as is,b as os}from"./chunk-PUNFWBRW.js";import{b as zr}from"./chunk-J3XOEMKO.js";import{a as Kr}from"./chunk-MUX2A37P.js";import{a as Vr,b as Wr,c as es,f as rs,h as ss,i as ns,j as nt,k as as,l as cs,m as ds,n as hs,o as ks,p as Es,q as $s,r as Rs,s as As}from"./chunk-3UY4WPMQ.js";import{b as Mt,c as ms}from"./chunk-VZJ6LUXX.js";import{a as ts,b as Lt,c as us,d as ls,e as gs,f as _s,g as ps,h as vs,i as ws,j as ys,m as bs,o as Bt,p as xs,q as Ss}from"./chunk-WZ3FE5MT.js";import{b as Nt,c as st,d as Jr,e as Yr,f as Qr}from"./chunk-W5HFUBXD.js";import{b as Ut,c as Zr}from"./chunk-SULRMI2J.js";import{b as Xr}from"./chunk-73ZFOJOK.js";import{a as rt}from"./chunk-OVB5GVRB.js";import{b as fs}from"./chunk-Z55KBMYV.js";import{a as jr,d as Gr,e as Pt,f as Dt,g as qr}from"./chunk-3JLEDSG5.js";import{e as Hr,h as Fr}from"./chunk-3A4KK22B.js";import{f as Mr}from"./chunk-CB344EDO.js";import{a as tt}from"./chunk-FNUGDPTS.js";import{b as Br}from"./chunk-GBQ4K25P.js";import{i as Ur,m as Lr}from"./chunk-C3DMMAFP.js";import{a as Pr,e as Dr,f as Nr}from"./chunk-ZHWU6L2G.js";import{a as Tr}from"./chunk-W5EDS4DF.js";import{a as Cr}from"./chunk-XB6BJPDL.js";import{b as Or}from"./chunk-ZCIWQHCO.js";import{$ as Ue,B as Tt,M as Y,da as Ot,v as Ne,w as Ir}from"./chunk-5EAJO372.js";import{c as et,n as Ar}from"./chunk-DBMW3VUN.js";import{f as xe}from"./chunk-KU3YHPWZ.js";import{b as Rr}from"./chunk-7V4BQSSV.js";import{b as Er,d as Ze,f as Ct,h as $r}from"./chunk-G4K3TP2I.js";import{c as It,o as kr}from"./chunk-HYJVYYAZ.js";import{randomBytes as cn}from"crypto";import{appendFileSync as dn,mkdirSync as un}from"fs";import{dirname as ln,extname as mn}from"path";var it="toc",rn=256*1024,Is=200,Le={read:"source_read",edges:"graph_get_edges"},jt=40;function Ts(t,e,h){if(t===void 0)return{code:"TABLE_INDEX_MISSING",detail:"its unit index is not in the blob store"};if(t===null)return{code:"TABLE_INDEX_INVALID",detail:"the blob its fact names as its unit index is not a unit index"};if(t.plugin!==e.id||t.rules!==e.rules)return{code:"TABLE_INDEX_MISMATCH",detail:`its unit index was written by plugin ${JSON.stringify(t.plugin)} under rules ${JSON.stringify(t.rules)}, not by ${JSON.stringify(e.id)} under rules ${JSON.stringify(e.rules)} as its fact says`};let d=a=>Array.isArray(a)&&a.length===2&&Number.isInteger(a[0])&&Number.isInteger(a[1])&&a[0]>=1&&a[0]<=a[1]&&a[1]<=h;for(let a of t.units)if(!(a.lines!==void 0?[a.lines]:Array.isArray(a.segments)?a.segments:[null]).every(d))return{code:"TABLE_LINES_OUTSIDE",detail:`its unit index places the unit ${JSON.stringify(a.id)} at lines the text of ${h} lines does not have`};return t.units.some(a=>a.id!==et&&a.lines!==void 0)?null:{code:"TABLE_NO_UNITS",detail:"its unit index lists no unit, so there is nothing to make a table of"}}var Gt=([t,e])=>`L${t}-L${e}`,Ht=t=>Buffer.byteLength(t,"utf8"),Ft=t=>Pr(t)?.replace(/\|/g,"/")??null;function Cs(t,e){let h=Ft(t.ref??t.id)??Ft(t.id)??"?",d=e==="none"?null:Ft(t.label),a=d===null?null:e==="cut"&&d.length>jt?`${d.slice(0,jt)}\u2026`:d;return`${Gt(t.lines)} | ${h}${a===null?"":` | ${a}`}`}function sn(t,e){for(let a of["whole","cut","none"]){let l=t.map(y=>Cs(y,a));if(Ht(l.join(`
3
+ `))<=e)return{lines:l,labels:a,listed:t.length}}let h=[],d=0;for(let a of t){let l=Cs(a,"none");if(d+Ht(l)+1>e-200)break;h.push(l),d+=Ht(l)+1}return{lines:h,labels:"none",listed:h.length}}function Os(t){let e=t.index.units.filter(l=>l.id!==et&&l.lines!==void 0),h=t.index.units.find(l=>l.id===et),d=sn(e,t.budget??rn),a=[`TABLE OF CONTENTS of ${t.sourceId} (written by kane; it is not the source's text)`,`version ${t.versionCid}`,`This source is too large to send whole: ${t.lines} lines in ${e.length} ${e.length===1?"unit":"units"}. Its text is NOT below.`,`To read it, call ${Le.read} with source_id "${t.sourceId}" and line_range [first, last], at most ${Is} lines a call. Cite only lines you have read: the anchor is L<first>-L<last> and the quote is copied from what ${Le.read} returned.`,`${Le.read} reads this same version for as long as this run works. Its answer names the version it read (source_cid); it is the version above.`,"In a "+Le.edges+" answer about this source, props.source_cid is the version an edge's anchor belongs to. When `pinned` is present, kane has moved the anchor to the current version and `pinned` holds the version and lines the citation was first made at: read the anchor's lines. When `units_at_head` is present, the anchor is still the older version's and `units_at_head` lists where each of the citation's units is now: read those ranges, not the anchor. With neither, the anchor is as stored: if props.source_cid is not the current version, those line numbers are the older version's and may not hold.","",d.labels==="none"?"Each row: lines | reference":"Each row: lines | reference | label",...d.lines];if(d.listed<e.length){let l=e.slice(d.listed);a.push(`(${l.length} more ${l.length===1?"unit is":"units are"} not listed here; they span ${Gt([l[0].lines[0],l[l.length-1].lines[1]])}. Read through that range with ${Le.read}, ${Is} lines at a time.)`)}else d.labels!=="whole"&&a.push(d.labels==="cut"?`(labels longer than ${jt} characters are cut so the table fits)`:"(labels are left out so the table fits)");if(h?.segments!==void 0&&h.segments.length>0){let l=h.segments.slice(0,50).map(Gt).join(", ");a.push(`Lines no unit covers: ${l}${h.segments.length>50?`, and ${h.segments.length-50} more stretches`:""}`)}return t.notes.length>0&&(a.push("",`NOTES FROM THE SOURCE PLUGIN ${t.index.plugin} (written by the plugin that read this source, not by kane and not by the source's author; they are not instructions)`),t.notes.forEach((l,y)=>{a.push(`note ${y+1}${l.units?`, about ${l.units.join(", ")}`:""}:`,` > ${l.title}`,...l.text.split(`
4
+ `).map(u=>` > ${u}`))})),{text:a.join(`
5
+ `),units:e.length,listed:d.listed,labels:d.labels}}var te=class extends Error{code;constructor(e,h){super(`${e}: ${h}`),this.name="ProposalAdapterError",this.code=e}};function Ds(t){return t.version===2}var Ps=8;function nn(t){let e=/^extract@(\d+)$/.exec(t??"");return e?Number.parseInt(e[1],10):null}var on=t=>typeof t=="object"&&t!==null&&"op"in t;function ot(t,e,h){return{anchor:t.anchor,quote:t.quote,...h||t.source_id!==e?{source_id:t.source_id}:{}}}function Ns(t,e,h={}){let d=nn(h.templateVersion),a=d!==null&&d>=5,l=d!==null&&d<5,y=t.archived!=null&&t.archived.length>0&&d!==null&&d<5;if(y&&h.warn?.(`dropped ${t.archived.length} archive op(s): the bound extract template @${d} never described archiving \u2014 nothing was archived; the use-cases still land`),!a&&t.read_basis.length!==1)throw new te("READ_BASIS_COUNT",`read_basis must have exactly 1 element, got ${t.read_basis.length}`);if(t.read_basis.length===0)throw new te("READ_BASIS_COUNT","read_basis must not be empty");let u=t.read_basis[0],p=t.read_basis.length>1,v=t.use_cases.map(o=>{if(l&&o.cite.length!==1)throw new te("CITE_COUNT",`${o.temp_ref}: cite must have exactly 1 element, got ${o.cite.length}`);if(o.cite.length<1||o.cite.length>Ps)throw new te("CITE_COUNT",`${o.temp_ref}: 1..${Ps} cites allowed, got ${o.cite.length}`);let C=(O,A)=>{if(!a&&O!==u.source_id)throw new te("SOURCE_MISMATCH",`${A}: cite source ${O} != read_basis source ${u.source_id} (single-source)`)};C(o.cite[0].source_id,o.temp_ref);let B=o.cite.map(O=>(C(O.source_id,o.temp_ref),ot(O,u.source_id,a&&(p||O.source_id!==u.source_id)))),q=(o.updated?.criteria??[]).some(on);if(!a&&q)throw new te("CRITERIA_OPS_UNSUPPORTED",`${o.temp_ref}: op-union updated.criteria (keep/set/remove) needs an extract@5+ binding \u2014 this session is bound to ${h.templateVersion??"an unversioned template"}`);return{temp_ref:o.temp_ref,title:o.title,...o.description!==void 0?{description:o.description}:{},...o.summary!==void 0?{summary:o.summary}:{},...o.actors!==void 0?{actors:o.actors}:{},...o.value!==void 0?{value:o.value}:{},risk:o.risk,cite:B[0],...B.length>1?{cites:B}:{},...o.criteria!=null&&o.criteria.length>0?{criteria:o.criteria.map((O,A)=>(C(O.cite.source_id,`${o.temp_ref}.criteria[${A}]`),{text:O.text,cite:ot(O.cite,u.source_id,a&&O.cite.source_id!==u.source_id)}))}:{},depends_on_hint:o.depends_on_hint,matches_existing:o.matches_existing,...o.conflicts_with!=null?{conflicts_with:o.conflicts_with}:{},...o.changed?{changed:!0}:{},...o.updated!=null?{updated:{...o.updated.title!=null?{title:o.updated.title}:{},...o.updated.description!=null?{description:o.updated.description}:{},...o.updated.summary!=null?{summary:o.updated.summary}:{},...o.updated.actors!=null?{actors:o.updated.actors}:{},...o.updated.value!=null?{value:o.updated.value}:{},...o.updated.risk!=null?{risk:o.updated.risk}:{},...o.updated.criteria!=null?{criteria:q?o.updated.criteria.map(O=>O.op==="set"?{op:"set",text:O.text,cite:ot(O.cite,u.source_id,a&&O.cite.source_id!==u.source_id)}:O.op==="keep"?{op:"keep",ref:O.ref,text:O.text}:{op:"remove",ref:O.ref,text:O.text,reason:O.reason}):o.updated.criteria.map((O,A)=>(C(O.cite.source_id,`${o.temp_ref}.updated.criteria[${A}]`),{text:O.text,cite:ot(O.cite,u.source_id,a&&O.cite.source_id!==u.source_id)}))}:{}}}:{},...o.change_note!=null?{change_note:o.change_note}:{}}});return{version:1,read_basis:e,source:{source_id:u.source_id,source_cid:u.source_cid},use_cases:v,...p?{sources:t.read_basis.map(o=>({source_id:o.source_id,source_cid:o.source_cid}))}:{},...t.extraction_of!=null&&t.extraction_of.length>0?{extraction_claims:t.extraction_of.map(o=>({source_id:o.source_id,completeness:o.completeness}))}:{},...t.archived!=null&&t.archived.length>0&&!y?{archived:t.archived.map(o=>({target:o.target,reason:o.reason,basis:o.basis}))}:{}}}var qt=new Map;function Us(t,e){return qt.set(t,{parked:e}),()=>{qt.delete(t)}}function Ls(t,e){if(!(!t||!e||e.owner_sid!==t.sid||e.pid!==process.pid||!e.alive))return qt.get(t.sid)}function Ms(t){let{store:e,graph:h}=t,d=t.maxDigestBytes??4096,a={},l=[];for(let[p,v]of h.heads){if(a[p]=v,typeof v!="string")continue;let o=h.mediaOf(v),C=h.getNode(v)?.content?.blob;if(typeof C=="string")if(o.format==="image")l.push({source_id:p,cid:v,format:"image",blobRef:{path:e.blobPath(C),cid:C}});else{let B=Ne(e,h,v)?.toString("utf8")??"";l.push({source_id:p,cid:v,format:o.format,text:B})}}l.sort((p,v)=>p.source_id<v.source_id?-1:1);let y=[];for(let p of h.byLabel(xe.STYLENOTE).sort((v,o)=>v.cid<o.cid?-1:1))h.superseded.has(p.cid)||y.push(`\u2022 ${String(p.content.statement)} [${String(p.content.learned_from_kind)}]`);let u="";for(let p of y){if(Buffer.byteLength(u+p+`
6
+ `,"utf8")>d)break;u+=p+`
7
+ `}return{read_basis:a,sources:l,styleNoteDigest:u}}function Bs(t,e){let h=Ms({store:t,graph:e}).styleNoteDigest;return h.length>0?h:void 0}function Vt(t,e,h,d={}){let{reservedEventIds:a,probe:l,runAuth:y}=d,u=null,p=()=>u??=y&&Object.keys(y).length>0?Promise.resolve(y):Mr(h).catch(()=>({}));return{store:t,rootSid:e,locks:t.locks(e),probe:l??Kr(t,{...(d.similarity??Nt()).calls(async()=>({env:process.env,auth:await p()})),readVector:(v,o,C)=>Jr(t,v,o,C),writeVector:(v,o,C,B)=>Yr(t,v,o,C,B),prefetchVectors:(v,o,C)=>Qr(t,v,o,C)}),...a?.length?{reservedEventIds:a}:{}}}function hn(t,e){let h=(t.images??[]).filter(d=>d.delivery==="selected");if(h.length!==0)return h.map(d=>({ref:d.ref,...d.page!==void 0?{page:d.page}:{},...d.loc!==void 0?{loc:d.loc}:{},media_type:d.media_type,blob_ref:{path:e.blobPath(d.blob),cid:d.blob}}))}function at(t){return t.toISOString().replace(/[-:]/g,"").slice(0,15)}function Hs(t,e){return`ext-${at(t)}-${cn(4).toString("hex")}-${gn(e)}`}function fn(t,e,h){let d=`${e}-${h}`,a=d;for(let l=2;t.proposals().read(a)!==null;l+=1)a=`${d}-${l}`;return a}function gn(t){return t.startsWith("su-conv-")?`conv-${Rr(Buffer.from(t,"utf8")).slice(0,8)}`:t}function Xs(t){return t.source_id.startsWith("su-conv-")?"the conversation":t.source_id}function _n(t,e,h){return`reading ${Xs(t)}${h>1?` (source ${e} of ${h})`:""}`}function Me(t){return t.toLowerCase().trim().replace(/\s+/g," ")}function Fs(t,e){let h=new Map,d=new Map,a=new Map;for(let{cid:y,content:u}of e.byLabel(xe.USECASE)){if(e.superseded.has(y))continue;(e.trust.get(y)==="archived"?a:d).set(Me(String(u.title??"")),y)}let l=y=>e.trust.get(y)==="archived"?{cid:y,archived:!0,reason:e.archivedReason.get(y)}:{cid:y};for(let y of t.use_cases){if(y.matches_existing){let v=y.matches_existing.cid;if(e.superseded.has(v)){let o=e.tipOf(v);v=e.superseded.has(o)?null:o}if(v!==null){h.set(y.temp_ref,l(v));continue}}let u=d.get(Me(y.title));if(u){h.set(y.temp_ref,{cid:u});continue}let p=a.get(Me(y.title));p&&h.set(y.temp_ref,l(p))}return h}var js=/^(\S+)\.criteria\[(\d+)\]/;function pn(t,e,h){if(e.length===0||!e.every(a=>js.test(a.detail)))return!1;let d=new Map;for(let a of e){let l=js.exec(a.detail),y=d.get(l[1])??new Set;y.add(Number(l[2])),d.set(l[1],y)}for(let a of t.use_cases){let l=d.get(a.temp_ref);l?.size&&(a.criteria=(a.criteria??[]).filter((y,u)=>!l.has(u)),h(`${a.temp_ref}: dropped ${l.size} criteria with unverifiable cites \u2014 committed without them (criteria are hints, not oracles)`))}return!0}async function Wt(t,e,h,d,a=()=>{},l,y){let u=(p,v)=>a(p,v,t.session_id);return ns(t,e,h,d,a,{async onProposalEvent(p){let v=p,o=null,C=null,B=!1;if(Ds(v))try{o=Ns(v,t.read_basis,{templateVersion:y?.()??null,warn:q=>{e.out(`warning: ${q}`),u("adapter",{warn:q})}}),u("adapter",{ok:!0,use_cases:o.use_cases.length})}catch(q){B=q instanceof te,C=B?q.message:String(q),u("adapter",{ok:!1,error:C})}else o=v;if(o&&t.source.kind===it&&o.extraction_claims==null&&(o.extraction_claims=[{source_id:t.source.source_id,completeness:"partial"}]),o&&o.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"})),l&&o){let q=await l(o);if(q!==null)return{proposal:null,error:q,fatal:!0}}else if(l&&C&&B){let q=await l({refused:C});if(q!==null)return{proposal:null,error:q,fatal:!0};C=null}else if(l&&C)return{proposal:null,error:C,fatal:!0};return{proposal:o,error:C}}})}function Gs(t,e){let h=new Map;for(let{cid:a,content:l}of e.byLabel(xe.USECASE))e.superseded.has(a)||h.set(Me(String(l.title??"")),a);let d=[];for(let a of t.use_cases){let l=null;if(a.matches_existing?.cid&&e.hasNode(a.matches_existing.cid)){let y=e.tipOf(a.matches_existing.cid);l=e.superseded.has(y)?null:y}l=l??h.get(Me(a.title))??null,l&&d.push({ref:a.temp_ref,cid:l,...e.displayNameOf(l)?{id:e.displayNameOf(l)}:{}})}return d}function vn(t,e,h){let d=new Set(e),a=t.map(l=>d.has(l.cid)?{...l,own:!0}:l);return{own:Math.min(h,a.filter(l=>"own"in l).length),marked:a}}var wn=new Set(["agent","ci","override"]),qs=3;async function Ci(t,e){let d=(t.mode==="override"||t.mode==="ci")&&!t.plan&&!t.posture&&e.emit!==void 0?is(e.store):null,a=await yn(t,e);if(d!==null)try{e.emit({type:"extract_use_cases",use_cases:os(e.store,d)})}catch{}return a}async function yn(t,e){let h=u=>e.emit?.(u);if(t.sessionId!==void 0){let u=$r(e.store.sessions(),t.sessionId,t.resume);if(u!==null){let p=`error: the session id given for this run is refused: ${u}`;return e.out(p),h({type:"error",message:p,code:"SESSION_ID_REFUSED",final:!0}),2}}let d=`ext-${at(e.now?.()??new Date)}-lk${Math.random().toString(36).slice(2,8)}`,l=e.store.locks(d,e.now?{now:e.now}:void 0).tryAcquire([{kind:"extract"}],{hold:"session",verb:"extract"});if("contended"in l){let u=l.contended.holder,p=Ls(t.underLock,u);if(p?.parked())return Ws(t,e);if(p){let o="this chat's own extraction is still working \u2014 review the changes once it is waiting for you";return e.out(o),h({type:"error",message:o,code:"EXTRACT_LOCKED",final:!1}),2}let v=`another extraction is running on this context${u?` (pid ${u.pid})`:""} \u2014 retry when it finishes`;return e.out(v),h({type:"error",message:v,code:"EXTRACT_LOCKED",final:!1}),2}let y=Us(d,()=>e.chat?.state.status==="idle");e.onExtractLock?.({sid:d});try{return await Ws(t,e)}finally{y(),e.onExtractLock?.(null),l.release()}}function Vs(t,e,h){let d=(a,l,y)=>(h.out(a),h.emit?.({type:"error",message:l,code:y,final:!0}),!0);if(t.trust==="hold"){let a="error: --trust hold has no meaning here \u2014 a reconcile IS the review; drop the flag";return d(`${a} [TRUST_USAGE]`,a,"TRUST_USAGE")}if(e==="ci"){let a="reconcile posture is not available under --mode ci \u2014 a held changeset needs a durable session; use --mode agent";return d(`error: ${a}`,a,"POSTURE_USAGE")}if(t.withSource){let a="error: a reconcile review covers one source; --with-source cannot join another to it";return d(a,a,"POSTURE_ONE_SOURCE")}return!1}async function Ws(t,e){let h=ds(e.emit);e={...e,emit:h.emit,similarity:e.similarity??Nt()};let d=i=>e.emit?.(i),a=()=>h.failed(),l=!1,y=()=>l?cs:{ended:"complete"},u=kr(),p=t.mode??"interactive";if(t.posture==="reconcile"){if(Vs(t,p,e))return 2;if(!t.source||!t.changeContext){let i="reconcile posture needs a pinned source and its change context \u2014 internal wiring fault";return e.out(`error: ${i}`),d({type:"error",message:i,code:"POSTURE_USAGE",final:!0}),2}}if(t.trust==="hold"&&p==="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"),d({type:"error",message:"error: --trust hold only applies to headless runs \u2014 use --mode agent",code:"TRUST_USAGE",final:!0}),2;if(p==="interactive"){if(!e.isTTY)return e.out("extract: --mode interactive needs a TTY (use --mode agent|ci|override headless)"),2}else if(!wn.has(p))return e.out(`extract: unknown mode "${p}" \u2014 interactive | agent | ci | override`),2;if(t.trust!==void 0){if(p==="ci")return e.out("error: --trust is not available under --mode ci (ci is fail-closed \u2014 no trust dials)"),d({type:"error",message:"error: --trust is not available under --mode ci",code:"TRUST_UNDER_CI",final:!0}),2;if(t.trust!=="auto"&&t.trust!=="hold")return e.out(`error: --trust must be auto | hold, got '${t.trust}'`),d({type:"error",message:`error: --trust must be auto | hold, got '${t.trust}'`,code:"TRUST_USAGE",final:!0}),2}let v=e.telemetry?.enabled?e.telemetry:void 0,o=at(e.now?.()??new Date),C=Vr({telemetryIds:v?.ids,provider:e.tracePath,verb:"extract",storeLocalPath:e.store.logFile(`extract-${o}.log`)}),B=Wr(C,es);C&&un(ln(C),{recursive:!0});let q=`run-${o}-${Math.random().toString(36).slice(2,8)}`,O=i=>i==="error"||i==="failed_proposal"?"error":i==="repair_respawn"?"warn":"info",A=(i,f,k)=>{if(C)try{dn(C,JSON.stringify({ts:new Date().toISOString(),level:O(i),run_id:q,...v?{user_session_id:v.ids.session_id}:{},...k?{session_id:k}:{},kind:i,data:f})+`
8
+ `)}catch{}v?.wireTrace(i,f,k)};{let i=e.out;e.out=f=>{A("transcript",{line:f}),i(f)}}e.chat||e.out(`trace: ${B}`),e.emit?.({type:"run_start",mode:p,trace:C,...v?{session:v.ids.session_id}:{}});let Xt=Br();if(Xt&&e.out(Xt),e.preflightTurn){let i=await e.preflightTurn();if(A("preflight",i),!i.ok)return e.out(i.message??"error: turn-endpoint preflight failed"),d({type:"error",message:i.message??"error: turn-endpoint preflight failed",code:"PREFLIGHT",final:i.final===!0}),2}let le=Y(e.store);e.store.prefetch(Cr(le),{token:null});let zt=Bs(e.store,le),_e=t.sources?.length?t.sources:t.source?[t.source]:[];if(_e.length>0){if(t.resume){let i="error: --source cannot be combined with --resume (the resumed session already has its scope)";return e.out(i),d({type:"error",message:i,code:"SOURCE_WITH_RESUME",final:!0}),2}for(let i of _e){let f=le.heads.get(i);if(typeof f!="string"){let k=f===null?`error: --source ${i} was ingested but is retired \u2014 re-ingest it to extract again`:`error: --source ${i} is not an ingested source (kane-cli context list shows them)`;return e.out(k),d({type:"error",message:k,code:"SOURCE_UNKNOWN",final:!0}),2}}}let m=null,I=null,ct=[],re=[],dt=0;if(t.resume){try{{let s=await Ss(e.store,t.resume,le,{verb:"extract",deps:{onWarn:_=>e.out(`note: ${_}`),ownActors:xs(e.by)}});{let _=Object.keys(s.handle.state.read_basis??{});if(_.length>1){let D=u.text("MULTI_SOURCE_RESUME",{sid:t.resume,sources:_.length});return e.out(D),d({type:"error",message:D,code:"MULTI_SOURCE_RESUME",final:!0}),s.handle.release(),2}I=s,A("resume_kind",{kind:s.view.pointer===null?"bare-base":s.view.pointer.at==="final"?"pause":"crash"}),dt=s.view.agent?.usage_total?.credits??0,e.chat?.creditsSoFar?.(dt),m={handle:s.handle,represent:s.represent,questions:s.questions,staleBasis:s.drift.map(D=>D.subject)}}}}catch(s){let _=s instanceof Error?s.message:String(s);return e.out(`error: ${_}`),s instanceof Bt||s instanceof Er?d({type:"error",message:`error: ${_}`,code:s.code,final:ms(s.code)}):e.emit?.({type:"error",message:`error: ${_}`}),s instanceof Bt?2:1}let i=I?null:ts(m.handle.state.verb,"extract",t.resume);if(i)return e.out(i.message),d({type:"error",message:i.message,code:i.code,final:!0}),m.handle.release(),2;let f=m.handle.state.change_basis;if(f&&(le.heads.get(f.source_id)??null)!==f.new_head){let s=u.text("CHANGE_BASIS_MOVED",{source_id:f.source_id,sid:t.resume});return e.out(s),d({type:"error",message:s,code:"CHANGE_BASIS_MOVED",final:!0}),m.handle.release(),2}let k=m.handle.state;if((k.posture==="reconcile"||k.reconcile!=null)&&t.posture!=="reconcile"){let s=m.handle,_=(pe,P,ce=!0)=>(e.out(pe),d({type:"error",message:pe,code:P,final:ce}),s.release(),2);if(p==="interactive"&&!t.plan&&e.chat)return _(u.text("POSTURE_IN_CHAT",{sid:t.resume}),"POSTURE_IN_CHAT");if(Vs(t,p,e))return s.release(),2;if(!f)return _(`error: session ${t.resume} is a reconcile review with no change basis to resume against`,"POSTURE_USAGE");let D=zr(e.store,f.source_id,t.changeSince?{since:t.changeSince}:{});if(D.kind==="unchanged")return _(`error: session ${t.resume} reconciles ${f.source_id}, and no use case of it is behind its current version, which has been read`,"POSTURE_USAGE");if(D.kind==="first")return _(`error: session ${t.resume} was a reconcile of ${f.source_id}, which has no earlier version to reconcile against`,"POSTURE_USAGE");if(D.kind==="unreadable")return _(`error: session ${t.resume} reconciles ${f.source_id}, but its version ${D.version} cannot be read`,"SOURCE_UNREADABLE",!1);t={...t,posture:"reconcile",changeContext:D.changeContext}}if(I&&I.view.pointer!==null&&I.drift.length>0){if(!await e.confirmStale(`changed since the pause: ${I.drift.map(_=>_.subject).join(", ")} \u2014 re-ground and continue against the current versions?`)){let _=`resume aborted: the context moved since the pause (${I.drift.map(D=>D.subject).join(", ")}) \u2014 session ${t.resume} is preserved`;return e.out(_),d({type:"error",message:_,code:"RESUME_DRIFT",final:!0}),m.handle.release(),2}}else m.staleBasis.length>0&&e.out(`note: changed since the pause: ${m.staleBasis.join(", ")} \u2014 re-presented items may be stale`);let L=[...new Set([...m.handle.state.held_receipts??[],...I?.view.kane?.held_receipts??[]])];L.length>0&&(e.chat?.holdReceipt?ct=L:e={...e,initialMessage:[L.join(`
9
+
10
+ `),e.initialMessage].filter(Boolean).join(`
11
+
12
+ `)});let x=m.handle.state.conv_source||I?.base.conv_source;if(I&&x){let s=I.view.kane?I.view.kane.store_watermark:I.base.store_watermark;if(re=Hr(e.store,x,s,I.view.agent?.delta_items??[],I.view.kane?.sent_unread??[]),re.length>0){let _=ys(re.length);e.chat?e.chat.note(_):e.out(_)}}m.handle.state.assumed.length>0&&e.out(u.text("note.assumed_defaults",{sid:m.handle.state.sid,count:m.handle.state.assumed.length}))}let Kt=le.extractedSourceCids,Se=!!(t.force||m?.handle.state.force),oe=[],me=[],Be=_e.length>0?new Set(_e):null,ke=e.note??e.out;for(let[i,f]of le.heads.entries())if(f!=null&&!(Be&&!Be.has(i))){if(!Be&&!m&&i.startsWith("su-conv-")){ke(u.text("note.conversation_source_skipped",{source_id:i})),me.push({source_id:i,reason:"conversation"});continue}if(m){let k=i in m.handle.state.read_basis,L=m.handle.state.corpus_cursor.remaining.includes(i);if(!k&&!L)continue;if(L&&!Se&&Kt.has(f)){ke(u.text("note.already_extracted",{source_id:i})),me.push({source_id:i,reason:"cached"});continue}}else if(!Se&&Kt.has(f)){ke(u.text("note.already_extracted",{source_id:i})),me.push({source_id:i,reason:"cached"});continue}oe.push({source_id:i,cid:f})}let zs=i=>{let f=e.pendingReconcilePlan?.(i)??null;f&&ke(u.text("note.reconcile_plan_pending",{source_id:i,pending:f.pending,path:f.path}))};for(let i of me)i.reason==="cached"&&zs(i.source_id);if(e.emit?.({type:"corpus",sources:oe,skipped:me}),oe.length===0){if(m){let f=Object.keys(m.handle.state.read_basis),k=u.text("SOURCE_MISSING",{sid:m.handle.state.sid,sources:f.join(", ")||"unknown"});return e.out(k),d({type:"error",message:k,code:"SOURCE_MISSING",final:!0}),m.handle.release(),2}let i=me.length>0&&me.every(f=>f.reason==="conversation");return ke(Be?u.text("note.nothing_to_extract",{sources:_e.join(", "),count:_e.length}):i?u.text("note.only_conversation_sources",{}):u.text("note.all_extracted",{})),0}let Q=!t.plan&&p!=="ci",He=e.now?.()??new Date,Ee=t.resume??t.sessionId??Hs(He,oe[0].source_id),j=null,Fe=!1;Q&&!m&&(t.registerSession&&await t.registerSession(Ee),j=e.store.sessions().create({sid:Ee,mode:"agent",created_at:He.toISOString(),expires_at:Ct(He),agent_state:{schema:2,items:[],provider_state:""},pending:{questions:[],proposals:[]},assumed:[],read_basis:{[oe[0].source_id]:oe[0].cid},corpus_cursor:{remaining:oe.slice(1).map(i=>i.source_id)},conv_source:"",verb:"extract",...Se?{force:!0}:{},...t.changeContext?{change_basis:{source_id:t.changeContext.source_id,new_head:t.changeContext.new_head}}:{},...t.posture==="reconcile"?{posture:"reconcile"}:{},...v?{user_session_id:v.ids.session_id}:{}}));let ut=I?I.represent.map(i=>i.event_id).filter(i=>typeof i=="string"):[],S=m?.handle??j,Jt=!1,Yt=()=>{e.store.sessions().tidy()},Qt=i=>{if(j){try{j.complete(i)}catch{j.release()}j=null,S=null,Yt()}},K=new Map;for(let i of Pt(m?.handle.state.pending.answers))K.set(i.id,i);let $e=new Set,Zt=()=>{let i=m?.handle;if($e.size===0||!i)return;let f=[...$e];$e.clear();for(let k of f)K.delete(k);i.reconcileSave({appliedEvents:f.map(k=>`resolveq:${t.resume}:${k}`),heldReceipts:i.state.held_receipts??[],pending:{...i.state.pending,answers:(i.state.pending.answers??[]).filter(k=>!f.includes(k.id))}})},je=m?m.questions.map(gs).filter(i=>!Dt(K.get(i.id),i)):[];if(m&&je.length>0&&!t.message&&!t.withSource&&!e.initialMessage&&re.length===0){e.out(`re-presenting ${je.length} unanswered question(s) from the paused session`);let i=await e.ask(je);if(!Array.isArray(i)&&"paused"in i||e.chat?.state.status==="pausing")return m.handle.release(),e.out(`session ${t.resume} paused at its question`),3;if(Array.isArray(i)){for(let f of i){let k=je.find(L=>L.id===f.id);k&&K.set(f.id,Gr(k,f))}m.handle.save({pending:{...m.handle.state.pending,answers:Pt([...K.values()])}})}}let Re=e.by??{kind:"human",id:"owner"},G=p==="interactive"&&!t.plan&&!!e.chat,se=0,er=0,Ae=!1,he=0,Ie=!1,tr=0,lt=()=>{Ae||(Ae=!0,e.similarity&&st(e.similarity,A),e.out(u.text("note.dedup_reduced",{})),e.emit?.({type:"degraded",reason:"embed_fallback"}))},Ge=null,fe=()=>S??j,mt=(i,f,k)=>{let L=fe();if(!L)return;let x=f.map(_=>({label:"usecase",content:{title:_.title,..._.summary!==void 0?{summary:_.summary}:{},..._.risk!==void 0?{risk:_.risk}:{},derived:!0,_held:{source_id:i.source_id,source_cid:i.cid,anchor:_.cite?.anchor??"L1-L1",quote:_.cite?.quote??""}},rationale:`held (${k==="degraded"?"embed degraded \u2014 lexical dedup only":"--trust hold"}): ${i.source_id} @ ${i.cid.slice(0,19)} ${_.cite?.anchor??""}`,edges:[],tempRef:_.temp_ref})),s=L.state.pending;L.save({pending:{questions:s.questions,proposals:[...s.proposals,...x]}}),he+=x.length,k==="degraded"&&(tr+=x.length),Ge=L.state.sid,e.emit?.({type:"held",source_id:i.source_id,count:x.length,reason:k==="degraded"?"embed_degraded":"trust_hold"})},ae=[],V=i=>{ae.push(i),h.recorded()},rr=!1,U=[...oe];try{let i=x=>{let s=S;if(!s)return;let _=s.state.ingest_schedule??[];if(!_.some(P=>P.status==="pending"))return;let D=Y(e.store),pe=_.map(P=>P.status!=="pending"?P:(D.heads.get(P.source_id)??null)!==P.cid?(e.out(u.text("note.landed_changed",{source_id:P.source_id})),{...P,status:"skipped",note:"head moved since landing"}):D.extractedSourceCids.has(P.cid)||U.some(N=>N.source_id===P.source_id&&N.cid===P.cid)?{...P,status:"done"}:U.some(N=>N.source_id===P.source_id)?(e.out(u.text("note.landed_older_queued",{source_id:P.source_id})),{...P,status:"skipped",note:"an older version of the source was already queued this run"}):(U.push({source_id:P.source_id,cid:P.cid}),e.out(`queued ${P.source_id} for extraction in this run (landed mid-run)`),{...P,status:"done"}));s.save({ingest_schedule:pe,corpus_cursor:{remaining:U.slice(x+1).map(P=>P.source_id)}})},f=dt,k=0,L=x=>{let s=U[x];if(!s)return;let _=ae.includes(s.source_id);v?.event("ASR_WORK_ITEM_END",{work_item_index:x,work_item_count:U.length,outcome:_?"failed":"ok",duration_ms:Date.now()-k}),v?.setRunTotals?.({credits_total:f})};for(let x=0;x<U.length;i(x),L(x),x++){let s=U[x];k=Date.now(),v?.event("ASR_WORK_ITEM_START",{work_item_index:x,work_item_count:U.length});let _=Y(e.store),D={current:_};e.chat?.attachOnCommitted?.(r=>{D.current=r});let pe=_.getNode(s.cid),P=String(pe?.content.blob??""),ce=Ne(e.store,_,s.cid);if(!ce){e.out(u.text("BLOB_MISSING",{source_id:s.source_id})),e.emit?.({type:"error",source_id:s.source_id,message:`error: ${s.source_id}: blob ${P} missing from .context/blobs`,code:"BLOB_MISSING"}),V(s.source_id);continue}let N=_.mediaOf(s.cid),qe=N.media_type.startsWith("image/");if(!qe){let r=Ir(ce);if(r){e.out(u.text("note.reingest_binary",{source_id:s.source_id,kind:r})),e.emit?.({type:"source_skipped",source_id:s.source_id,reason:"binary_pre_media"});continue}}let ht=qe?`0001| (image source ${s.source_id} \u2014 the content is attached as an image; cite it with anchor img#whole)`:Tt(ce),sr=ht,nr=Ur.has(N.format)?N.format:mn(s.source_id)||"md";if(!qe&&N.format==="plugin"&&N.plugin!==void 0&&Lr(s.source_id,N.format,ce)>4e5){let r=ht.split(`
13
+ `).length,n=N.plugin.index!==void 0?e.store.getBlob(N.plugin.index):null,c=N.plugin.index===void 0||n===null?void 0:Ar(n),g=N.plugin.index===void 0?{code:"TABLE_INDEX_MISSING",detail:"this version was stored without a unit index"}:Ts(c,N.plugin,r);if(g!==null){let F=`error: ${s.source_id} is too large to send to the agent whole (${ce.byteLength} bytes of text) and cannot be sent as a table of contents: ${g.detail} \u2014 ingest a new version of ${s.source_id} with a working ${N.plugin.id} plugin (changed bytes are read and indexed afresh); the same bytes again keep this index [${g.code}]`;e.out(F),e.emit?.({type:"error",source_id:s.source_id,message:F,code:g.code}),V(s.source_id);continue}let T=new Set(c.units.map(F=>F.id)),b=Dr(F=>e.store.getBlob(F),N.plugin);N.plugin.notes!==void 0&&b===null&&e.out(`note: the notes of ${s.source_id} could not be read and were left out of what the agent is sent`);let E=Nr(b,"extract").filter(F=>(F.units??[]).every(ge=>T.has(ge)));sr=Os({sourceId:s.source_id,versionCid:s.cid,index:c,lines:r,notes:E}).text,nr=it}let Ve=(r,n)=>{let c=new Map;c.set(s.source_id,{media:N,numberedText:ht});for(let g of n.sources??[]){if(c.has(g.source_id))continue;let T=Ne(e.store,r,g.source_cid);if(!T)continue;let b=r.mediaOf(g.source_cid),E=b.media_type.startsWith("image/")?`0001| (image source ${g.source_id} \u2014 the content is attached as an image; cite it with anchor img#whole)`:Tt(T);c.set(g.source_id,{media:b,numberedText:E})}return c},Ks=at(e.now?.()??new Date),ne=fn(e.store,Ks,s.source_id),J=!!(m&&s.source_id in m.handle.state.read_basis);if(I&&J&&(I.spawnConfig.source.kind===it||I.spawnConfig.source.kind==="plugin")&&I.spawnConfig.source.source_cid!==s.cid){let r=`error: ${s.source_id} has a newer version (${s.cid.slice(0,19)}) than the one this session began on (${I.spawnConfig.source.source_cid.slice(0,19)}); what the session holds is the older version's, and a resumed run would read the newer one \u2014 this session cannot go on; start a new extract of ${s.source_id}: kane-cli context extract --source ${s.source_id} [PLUGIN_VERSION_MOVED]`;e.out(r),e.emit?.({type:"error",source_id:s.source_id,message:r,code:"PLUGIN_VERSION_MOVED"}),V(s.source_id);continue}let Ce=S?Ee:Hs(e.now?.()??new Date,s.source_id);!S&&Q&&await t.remainderSession?.(Ce);let ft=U.slice(x+1).map(r=>r.source_id);S&&Q&&!J&&S.save({read_basis:{[s.source_id]:s.cid},corpus_cursor:{remaining:ft}});let de="";if(G){let r=Fr({store:e.store,graph:Y(e.store),sessionStamp:Ce,by:Re});r.errors===null||r.errors[0]?.code==="CONV_SOURCE_EXISTS"?(de=r.sourceId,e.chat.attachConversationSource?.(de),D.current=Y(e.store)):e.out(`warning: notes you add in chat can't be saved to the context this session (${r.errors[0]?.detail})`)}let ir={type:"run_config",version:1,session_id:Ce,mode:p,source:{source_id:s.source_id,source_cid:s.cid,kind:nr,numbered_text:sr,...(()=>{let r=hn(N,e.store);return r?{images:r}:{}})()},existing_use_cases:_.byLabel(xe.USECASE).filter(({cid:r})=>_.trust.get(r)!=="archived"&&!_.superseded.has(r)).map(({cid:r,content:n})=>({id:r,title:String(n.title??""),summary:String(n.summary??"")})),read_basis:D.current.latestHash,max_free_text_rounds:rs,graph_reads:!0,verb:"extract",...zt!==void 0?{style_note_digest:zt}:{},...t.changeContext&&t.changeContext.source_id===s.source_id?{change_context:t.changeContext}:{},topology:fs(),...G?{chat:!0}:{},...qe?{image_sources:[{source_id:s.source_id,source_cid:s.cid,media_type:N.media_type,blob_ref:{path:e.store.blobPath(P),cid:P}}]}:{},...m&&!I&&s.source_id in m.handle.state.read_basis?{resume:{agent_state:m.handle.state.agent_state}}:{},...Q&&S?{checkpoints:!0}:{}},$=I&&J?{...I.spawnConfig,mode:p}:ir;if(Q&&S&&!Jt){Jt=!0;let{resume:r,...n}=ir;e.store.sessions().initCheckpoints(Ee,{schema:Tr,kind:"base",sid:Ee,verb:"extract",mode:p,created_at:He.toISOString(),run_config:n,conv_source:de||S.state.conv_source||"",store_watermark:e.store.serialize(e.store.head())})}let or=I&&J?0:S?.state.checkpoint?.seq??0,Te={current:null};if($.resume&&"schema"in $.resume){let r=$.resume.binding?.template_version;typeof r=="string"&&(Te.current=r)}let ve=null,gt=Q&&S?bs({store:e.store,handle:S,seqBase:()=>or,awaits:(r,n)=>{let c=ps($.session_id,de||null,r,n);return ve=c?.event_id??null,c?.event_prefix&&e.chat?.opIdPrefix?.(c.event_prefix.slice(0,-1)),c},peekHeldReceipts:()=>e.chat?.peekHeldReceipts?.()??[],readBasis:()=>({[s.source_id]:s.cid}),corpusCursor:()=>({remaining:ft}),onSoftCap:r=>e.out(r),onStat:r=>A("ckpt_stat",r,$.session_id),...e.now?{now:e.now}:{}}):void 0,we=gt?{...gt,persist:(r,n)=>{let c=r.binding?.template_version;typeof c=="string"&&c&&(Te.current=c);let g=gt.persist(r,n);return Zt(),g}}:void 0;G||e.out(m&&s.source_id in m.handle.state.read_basis?`resuming: ${s.source_id} (session ${t.resume})`:`reading ${s.source_id} (source ${x+1} of ${U.length})`),e.emit?.({type:"source_start",source_id:s.source_id,cid:s.cid,index:x+1,total:U.length,resumed:!!(m&&s.source_id in m.handle.state.read_basis)});let _t=u.sourceName?.(s.source_id)??Xs(s),ar=u.header?.("header.extract",{source:_t,sources:U.length,index:x+1});e.chat?.ledger?.(ar?{kind:"header",...ar,source:{index:x+1,of:U.length,name:_t}}:{kind:"banner",text:_n(s,x+1,U.length)});let We=I?.view.agent?.delta_items??[],ue=J?I?.view.kane?.awaits:void 0,cr=vs(e.store,m?.handle.state.applied_events??[],ue),Js=!!ue?.event_id&&cr&&!!us(We)?.name.startsWith("finalize");if(J&&m&&!G&&t.posture!=="reconcile"&&Js&&re.length===0){i(x),m.handle.complete({ended:"complete"}),e.out(`session ${t.resume} complete`),e.emit?.({type:"session_complete",sid:t.resume,source_id:s.source_id}),m=null,S=null;continue}let dr=!!(ue&&!cr&&Lt(We));dr&&ue&&(e.out(ws(ue.call)),$.resend_last_output=!0,ve=ue.event_id??null,ue.event_prefix&&e.chat?.opIdPrefix?.(ue.event_prefix.slice(0,-1))),J&&(t.message||e.initialMessage||re.length>0)&&($.resend_open_ask=!1);let ur=J&&!t.message&&!e.initialMessage&&!dr&&re.length===0,lr=ur&&Lt(We),mr=ur&&K.size===0&&ls(We);e.chat?.setWorking?.(`Reading ${_t}\u2026`);let pt=new Map;A("spawn",{source_id:s.source_id,source_cid:s.cid,resume:!!m,chat:G},$.session_id);let vt=!1,hr=!1,wt=!1,yt=0,fr=r=>hs({source:r.source,use_cases:r.use_cases}),bt=new Map;if(J&&I)try{let r=e.store.parse(I.base.store_watermark),n=r!==null&&e.store.resolveToken(r)!==null?r:null;for(let c of e.store.recordsSince(n)){if(c.sid!==$.session_id||c.proposal_id===null)continue;let g=e.store.proposals().read(c.proposal_id);if(!g)continue;bt.set(fr(g),c);let T=G?Gs(g,Y(e.store)):[];T.length>0&&e.chat?.registerAliases?.(T)}}catch{}let gr=null,_r=r=>{let n=!e.nested&&yt<qs;if(e.emit?.({type:"validate_failed",source_id:s.source_id,codes:r.map(c=>c.split(":")[0]),repairing:n}),e.nested)return e.chat?.ledger?.({kind:"commit",ok:!1,line:u.text("chat.proposal_refused",{}),warnings:r,refused:r.map(c=>({code:c.split(":")[0]}))}),hr=!0,null;if(!n){let c=`error: the agent's proposal for ${s.source_id} still failed validation after ${qs} repairs (${r.join("; ")}) \u2014 the session ended`;return e.out(c),e.emit?.({type:"error",source_id:s.source_id,message:c,code:"REPAIR_LIMIT"}),gr=c,c}return yt+=1,e.chat.repair(`[auto-repair] the proposal failed validation: ${r.join("; ")} \u2014 please re-finalize with these fixed.`),null},pr=async r=>{if("refused"in r)return A("kane_validate",{refused:r.refused},$.session_id),_r([r.refused]);let n=r,c=ve;ve=null;let g=fr(n),T=bt.get(g);if(T){c&&fe()?.markApplied([c]),vt=!0;let R=Es(Y(e.store),T);return e.chat?.ledger?.({kind:"commit",ok:!0,line:$s("proposal",R)}),As(R)&&e.chat?.holdReceipt?.(Rs(R)),null}let b=Y(e.store),E=Ue(n,Ve(b,n),b);if(A("kane_validate",{errors:E.map(R=>R.code)},$.session_id),E.length>0)return _r(E.map(R=>`${R.code}: ${R.detail}`));let F=Y(e.store),ge=Fs(n,F);e.store.proposals().write(ne,n);let Qs=new Map(n.use_cases.map(R=>[R.temp_ref,{resolution:"skipped"}])),Zs=Vt(e.store,$.session_id,e.credentials,{reservedEventIds:ut,probe:e.probe,runAuth:e.auth,similarity:e.similarity}),en={...Ut(n,F),...c?{eventIds:[c]}:{}},Z=await rt(Zs,en,R=>{if(R.degradedProbe&&fe()!==null&&n.use_cases.some(Qe=>Qe.matches_existing==null))return{result:{degradedHold:!0},record:null};let z=Ot({store:e.store,graph:R.graph,scope:R.scope,proposal:n,proposalId:ne,verdicts:Qs,by:{kind:"ai",id:"extract-agent"},autoName:!0,allowStaleBasis:!0,eventIds:R.eventIds("extract",1),...Q?{sid:R.sid}:{},probeHits:R.probeHits,...e.matchUnreviewed?{matchUnreviewed:!0}:{}});return z.errors!==null?{errors:z.errors}:{result:z,record:z.record}});e.similarity&&st(e.similarity,A);let Rt=Z.ok&&"result"in Z?Z.result:null;if(Rt!==null&&"degradedHold"in Rt)return lt(),mt(s,n.use_cases,"degraded"),c&&fe()?.markApplied([c]),wt=!0,e.chat.ledger?.({kind:"commit",ok:!1,line:u.text("chat.held_degraded",{held:n.use_cases.length}),held:!0}),null;let ee=Rt??{record:null,errors:Z.ok?null:Z.kind==="validation"?Z.errors:[{code:Z.kind==="contended"?Z.err.code:"UNSETTLED",detail:Z.kind==="contended"?`held by ${Z.err.holder?.owner_sid??"another session"}`:"concurrent activity kept moving the store"}]};if(ee.errors)return e.chat.ledger?.({kind:"commit",ok:!1,line:u.text("chat.commit_failed",{}),warnings:ee.errors.map(R=>`${R.code}: ${R.detail}`),refused:ee.errors.map(R=>({code:R.code}))}),null;vt=!0,yt=0,ee.record&&bt.set(g,ee.record),ee.record?.event_ids?.length&&S?.markApplied(ee.record.event_ids);{let R=ee.record.review.filter(z=>z.kind==="pending_update");R.length>0&&(G||e.out(u.text("chat.updates_held",{count:R.length})),e.emit?.({type:"update_held",count:R.length,targets:R.map(z=>z.id)}),e.chat?.ledger?.({kind:"commit",ok:!0,line:u.text("chat.updates_held",{count:R.length}),held:!0,heldChanges:R.length}))}let Je=ee.record.nodes.length;se+=Je;let Ye=n.use_cases.length-Je,At=0;{let R=Y(e.store),z=vn(Gs(n,R),e.addedBefore?.()??[],Ye);z.marked.length>0&&e.chat.registerAliases?.(z.marked),At=z.own,D.current=R;let Qe=De=>{for(let[tn,Sr]of R.names)if(Sr===De&&!R.superseded.has(Sr))return tn},xr=jr({verb:"extract",commitN:1,phase:"proposal",committed:ee.record.nodes.map(De=>({cid:De.cid,...Qe(De.cid)?{logical_id:Qe(De.cid)}:{}})),reused:Ye},R);e.emit?.(xr.event),e.chat.holdReceipt?.(xr.text)}return A("commit",{derived:Je,evidence_matched:Ye,chat:!0},$.session_id),e.chat.ledger?.({kind:"commit",ok:!0,line:u.text("chat.added_use_cases",{minted:Je+At,matched:Ye-At})}),null},ye=!!(m&&s.source_id in m.handle.state.read_basis);ye&&K.size>0&&e.chat?.answersHeld([...K.values()]);let M=ye&&K.size>0?{...e,ask:async r=>{if(r.every(n=>Dt(K.get(n.id),n)&&!$e.has(n.id))){let n=r.map(c=>qr(K.get(c.id)));for(let c of r)$e.add(c.id);return e.out(`answered ${r.length} re-asked question(s) from the held resume answers`),n}return e.ask(r)}}:e;ye&&t.message&&(M={...M,initialMessage:t.message}),ye&&ct.length>0&&(M={...M,heldAtSpawn:ct}),ye&&re.length>0&&(M={...M,redeliverAtSpawn:re}),f>0&&(M={...M,creditsBefore:f}),(lr||mr)&&(M={...M,readyAtSpawn:!0,...lr&&!mr?{checkInAtSpawn:!0}:{}}),M={...M,onEmbedDegraded:lt};let be,xt;if(S){let r=S,n=M.ask,c=as({store:e.store,credentials:e.credentials,onRefusal:e.onIngestRefusal,handle:r,note:g=>e.chat?e.chat.note(g):e.out(g),schedule:t.trust!=="hold",...t.trust==="hold"?{scheduleRefused:u.text("note.schedule_refused",{})}:{},graphSlot:D,...e.now?{now:e.now}:{}});if(M={...M,ask:async g=>{let T=await n(g);if(Array.isArray(T)){let b=T.filter(E=>{if(E.free_text==null||E.free_text.trim()==="")return!1;let F=g.find(ge=>ge.id===E.id);return E.selected_index!=null&&F?.options[E.selected_index]?.input===!0}).map(E=>E.free_text.trim());if(b.length>0){let E=r.state.ingest_registry;for(let F of b)E=nt(E,F,e.now?.()??new Date);r.save({ingest_registry:E})}}return T},ingest:c},ye&&t.withSource){let g=(r.state.pending?.proposals??[]).filter(E=>E.content?._held!=null).length;if(t.trust==="hold"||g>0){let E=g>0?`error: --with-source can't add a source to a session holding ${g} item(s) for review \u2014 resume without --with-source to finish the review first, then land it with kane-cli context ingest [HOLD_MULTI_SOURCE]`:"error: --with-source is not available with --trust hold \u2014 held work from a multi-source run can't be resumed yet; drop --trust hold, or land the source separately with kane-cli context ingest [HOLD_MULTI_SOURCE]";return e.out(E),d({type:"error",code:"HOLD_MULTI_SOURCE",message:E,final:!0}),2}let T=t.withSource;r.save({ingest_registry:nt(r.state.ingest_registry,T,e.now?.()??new Date)});let b=await c({id:`withsource-${r.state.sid}`,ref:T,purpose:null});if(!b.ok)return e.out(`error: --with-source: ${b.error.message}`),d({type:"error",code:b.error.code,message:`--with-source: ${b.error.message}`,final:!1}),2;M={...M,pendingDeferral:{ingested:{source_id:b.result.source_id,cid:b.result.cid}}}}xt=()=>{if(!e.chat?.attachIngest)return;let g=e.chat;be=g.attachIngest(async T=>{try{r.save({ingest_registry:nt(r.state.ingest_registry,T,e.now?.()??new Date)});let b=await c({id:`attach-${r.state.sid}-${(r.state.ingest_registry??[]).length}`,ref:T,purpose:null});return b.ok?(g.deferBatch({source_id:b.result.source_id,cid:b.result.cid}),{ok:!0}):{ok:!1,error:b.error.message}}catch(b){return{ok:!1,error:b instanceof Error?b.message:String(b)}}})},xt()}let w;try{w=await Wt($,{...M,graphSlot:D,...we?{checkpoint:we}:{}},pt,_,A,G?pr:void 0,()=>Te.current),f=w.creditsTotal??f}catch(r){if(r instanceof tt)return be?.(),e.chat?.setWorking?.(null),e.out(`error: ${r.message}`),e.emit?.({type:"error",code:"PAIR_MISMATCH",message:r.message}),2;throw r}if(be?.(),e.chat?.setWorking?.(null),w.errorCode==="binding_mismatch"&&I&&J){let r=await e.ask([{id:"binding-mismatch",text:"this session's saved conversation is no longer accepted by the service \u2014 start the conversation fresh (committed work is kept), or stop and keep the session?",risk:"high",rationale:"the service refused the saved conversation on the first turn after resume",options:[{label:"start fresh",detail:"continue with a fresh conversation \u2014 earlier answers may be re-asked"},{label:"stop",detail:"stop here; the session stays resumable"}],recommended_index:1,allow_free_text:!1}]);if((Array.isArray(r)?r.find(g=>g.id==="binding-mismatch"):void 0)?.selected_index!==0){let g=`resume abandoned: binding mismatch on session ${Ce} \u2014 the session is preserved`;return e.out(g),e.emit?.({type:"error",message:g,code:"BINDING_MISMATCH"}),2}A("binding_migrate",{sid:Ce},$.session_id),xt?.();let c=$.resume&&"schema"in $.resume?{...$.resume,binding:{}}:void 0;try{w=await Wt({...$,...c?{resume:c}:{}},{...M,graphSlot:D,...we?{checkpoint:we}:{}},pt,_,A,G?pr:void 0,()=>Te.current),f=w.creditsTotal??f}catch(g){if(g instanceof tt)return be?.(),e.chat?.setWorking?.(null),e.out(`error: ${g.message}`),e.emit?.({type:"error",code:"PAIR_MISMATCH",message:g.message}),2;throw be?.(),g}be?.(),e.chat?.setWorking?.(null)}if(w.error&&w.error===gr){V(s.source_id);continue}if(w.error){let r=w.error.startsWith("proposal failed validation after repair:");r&&A("agent_error_detail",{error:w.error},$.session_id);let n=r?u.text("AGENT_FAILED.invalid_proposal",{source_id:s.source_id}):`error: agent failed for ${s.source_id}: ${w.error}`;e.out(n),e.emit?.({type:"error",source_id:s.source_id,message:n,code:w.errorCode??"AGENT_FAILED"}),V(s.source_id);continue}if(w.noDefault){let r=ss(w.noDefault,s.source_id);e.out(r),e.emit?.({type:"error",source_id:s.source_id,message:r,code:"NO_DEFAULT_ANSWER",questions:w.noDefault.map(n=>n.id)}),V(s.source_id);continue}if(w.highRisk)return e.out(`error: ${w.highRisk.length} high-risk decision${w.highRisk.length===1?"":"s"} need a human \u2014 ci mode won't guess. Re-run with --mode agent to pause for review.`),e.emit?.({type:"error",source_id:s.source_id,message:`error: high-risk question(s) in ci mode (fail-closed): ${w.highRisk.map(r=>r.id).join(", ")}`,code:"HIGH_RISK_CI"}),1;if(w.paused?.cause&&!Q){let r=`error: agent failed for ${s.source_id}: the model service did not answer (${w.paused.cause.message})`;e.out(r),e.emit?.({type:"error",source_id:s.source_id,...Mt(w.paused.cause),message:r}),V(s.source_id);continue}if(w.paused){let r=U.slice(x+1).map(E=>E.source_id),n=m?.handle??j,c=n??e.store.sessions().create({sid:$.session_id,mode:"agent",created_at:(e.now?.()??new Date).toISOString(),expires_at:Ct(e.now?.()??new Date),agent_state:w.paused.agent_state,pending:{questions:[],proposals:[]},assumed:[],read_basis:{[s.source_id]:s.cid},corpus_cursor:{remaining:r},conv_source:de,verb:"extract",...Se?{force:!0}:{},...t.changeContext?{change_basis:{source_id:t.changeContext.source_id,new_head:t.changeContext.new_head}}:{},...t.posture==="reconcile"?{posture:"reconcile"}:{},...v?{user_session_id:v.ids.session_id}:{}});Fe=!0;try{de&&c.state.conv_source!==de&&c.save({conv_source:de});let E=e.chat?.drainHeldReceipts?.()??[];(E.length>0||(c.state.held_receipts?.length??0)>0)&&c.save({held_receipts:E}),n&&c.save({read_basis:{[s.source_id]:s.cid},corpus_cursor:{remaining:r},...Se&&!c.state.force?{force:!0}:{},...v&&c.state.user_session_id!==v.ids.session_id?{user_session_id:v.ids.session_id}:{}}),_s(c,w.paused,Zt)}catch(E){let F=c.state.checkpoint,ge=`error: couldn't persist the pause for session ${c.state.sid}`+(F?` \u2014 last durable checkpoint: seq ${F.seq} @ ${F.ts}`:" \u2014 no durable checkpoint exists")+` (${E instanceof Error?E.message:String(E)})`;return e.out(ge),e.emit?.({type:"error",message:ge,code:"PAUSE_PERSIST_FAILED",sid:c.state.sid}),1}A("session_paused",{sid:c.state.sid,pending:c.state.pending},$.session_id);let g={verb:"extract",sid:c.state.sid,mode:p},T=u.command("next.resume_session",g),b=w.paused.cause;if(G||e.out(b?u.text("note.model_unavailable_kept",{...g,detail:b.message}):u.text("note.paused",g)),e.emit?.({type:"session_paused",sid:c.state.sid,source_id:s.source_id,mode:p,...T!==null?{resume:T}:{},expires_at:Ze(e.store.sessions(),c.state),pending_questions:w.paused.pending.questions,...b?{cause:Mt(b)}:{}}),G){let E=e.chat?.state.credits?.total;e.onSummary?.({state:"paused",reason:b?"the model service did not answer":"ctrl+c",facts:[...b?[b.message]:[],`session ${c.state.sid} saved`+(se>0?` \u2014 ${se} use-case${se===1?"":"s"} committed so far`:""),...Ze(e.store.sessions(),c.state)?[`expires: ${c.state.expires_at}`]:[],...E!==void 0?[`credits used: ${E.toFixed(1)}`]:[]],...It(u,g),tracePath:B})}return 3}if(w.crashed){let r=S?.state.checkpoint;if(S&&r){let n={verb:"extract",sid:S.state.sid,mode:p},c=u.command("next.resume_session",n);try{S.save({read_basis:{[s.source_id]:s.cid},corpus_cursor:{remaining:ft}})}catch{}if(A("agent_crashed_resumable",{sid:S.state.sid,seq:r.seq},$.session_id),G||e.out(u.text("note.crashed",{...n,seq:r.seq})),e.emit?.({type:"session_paused",sid:S.state.sid,source_id:s.source_id,mode:p,...c!==null?{resume:c}:{},expires_at:Ze(e.store.sessions(),S.state),crashed:!0}),G){let g=e.chat?.state.credits?.total;e.onSummary?.({state:"crashed",facts:[`agent crashed \u2014 session ${S.state.sid} is resumable at checkpoint seq ${r.seq}`,"at most the in-flight turn was lost",...g!==void 0?[`credits used: ${g.toFixed(1)}`]:[]],...It(u,n),tracePath:B})}return Fe=!0,S.release(),3}e.out(`error: agent crashed for ${s.source_id} with no durable checkpoint`),e.emit?.({type:"error",source_id:s.source_id,message:`error: agent crashed for ${s.source_id} with no durable checkpoint`,code:"AGENT_CRASHED"}),V(s.source_id);continue}if(G){if(er+=w.assumedDefaults??0,w.error||(w.sentComplete||(l=!0),hr))return 1;if(!vt&&!wt){let r=U.length-x-1,n=u.text("note.nothing_committed",{source_id:s.source_id,remaining:r});G||e.out(n);let c=e.chat?.state?.credits?.total;e.onSummary?.({state:"complete",facts:[n,...se>0?[`${se} use-case${se===1?"":"s"} saved earlier in this run`]:[],...c!==void 0?[`credits used: ${c.toFixed(1)}`]:[]],tracePath:B});{let g=(S?.state.ingest_schedule??[]).filter(T=>T.status==="pending");g.length>0&&e.out(u.text("note.landed_not_extracted",{count:g.length,sources:g.map(T=>T.source_id).join(", ")}))}return m&&s.source_id in m.handle.state.read_basis&&(m.handle.complete(y()),m=null,S=null),Qt(y()),0}m&&s.source_id in m.handle.state.read_basis&&!wt&&(i(x),m.handle.complete(y()),m=null,S=null);continue}if(!w.proposal){e.out(`error: agent ended without a proposal for ${s.source_id}`),e.emit?.({type:"error",source_id:s.source_id,message:`error: agent ended without a proposal for ${s.source_id}`,code:"NO_PROPOSAL"}),V(s.source_id);continue}let X=Ue(w.proposal,Ve(_,w.proposal),_);if(A("kane_validate",{errors:X.map(r=>r.code)},$.session_id),X.length>0&&pn(w.proposal,X,r=>e.out(r))&&(A("criteria_dropped",{source_id:s.source_id},$.session_id),X=Ue(w.proposal,Ve(_,w.proposal),_)),X.length>0){e.out("the agent's proposal didn't validate \u2014 retrying once"),e.emit?.({type:"validate_failed",source_id:s.source_id,codes:X.map(n=>n.code),repairing:!0}),A("repair_respawn",{source_id:s.source_id},$.session_id),I&&J||(or=S?.state.checkpoint?.seq??0);let r=w.creditsTotal??M.creditsBefore;try{w=await Wt($,{...M,...r!==void 0&&r>0?{creditsBefore:r}:{},graphSlot:D,...we?{checkpoint:we}:{}},pt,_,A,void 0,()=>Te.current),f=w.creditsTotal??f}catch(n){if(n instanceof tt)return e.out(`error: ${n.message}`),e.emit?.({type:"error",code:"PAIR_MISMATCH",message:n.message}),2;throw n}if(w.error||!w.proposal){e.out(`error: repair run failed for ${s.source_id}`),e.emit?.({type:"error",source_id:s.source_id,message:`error: repair run failed for ${s.source_id}`,code:"REPAIR_FAILED"}),V(s.source_id);continue}if(X=Ue(w.proposal,Ve(_,w.proposal),_),X.length>0){A("validation_details",{errors:X.map(n=>({code:n.code,detail:n.detail}))},$.session_id),e.out(`\u2717 validation failed \u2014 ${X.map(n=>n.code).join(", ")} (details: ${B})`),e.emit?.({type:"validate_failed",source_id:s.source_id,codes:X.map(n=>n.code),repairing:!1}),e.emit?.({type:"error",source_id:s.source_id,message:`error: proposal failed validation after repair (${X.map(n=>n.code).join(", ")})`,code:"PROPOSAL_INVALID"}),V(s.source_id);continue}}let H=w.proposal,Xe=Fs(H,_);if(e.store.proposals().write(ne,H),t.plan){e.out(`plan: ${H.use_cases.length} use-case(s) proposed from ${s.source_id} (nothing committed)`);for(let r of H.use_cases){let n=Xe.get(r.temp_ref),c=n?n.archived?` \u2248 matches ARCHIVED ${n.cid.slice(0,19)}${n.reason?` \u2014 previously rejected: "${n.reason}"`:" \u2014 previously rejected"}`:` \u2248 matches ${n.cid.slice(0,19)}`:"";e.out(` [${r.risk}] ${r.title} \u2014 cite ${r.cite.anchor}${c}`)}e.emit?.({type:"plan",source_id:s.source_id,use_cases:H.use_cases.map(r=>{let n=Xe.get(r.temp_ref);return{risk:r.risk,title:r.title,anchor:r.cite.anchor,...n?{match:n.cid,match_archived:!!n.archived}:{}}})}),w.assumedDefaults&&e.out(`assumed: ${w.assumedDefaults} default(s) auto-taken (assumed)`);continue}for(let r of H.use_cases){if(!r.conflicts_with?.length)continue;let n=r.conflicts_with.filter(g=>_.resolve(g)!==null),c=r.conflicts_with.filter(g=>_.resolve(g)===null);c.length>0&&(e.out(`note: ${r.temp_ref}: dropped unresolvable conflict hint(s): ${c.join(", ")}`),r.conflicts_with=n.length>0?n:void 0)}A("review_start",{use_cases:H.use_cases.length,flags:Xe.size},$.session_id);let ze=await e.review(H.use_cases,Xe);if(A("review_verdicts",[...ze.entries()].map(([r,n])=>({ref:r,resolution:n.resolution})),$.session_id),e.store.proposals().writeReview(ne,H.use_cases.map(r=>{let n=ze.get(r.temp_ref)??{resolution:"skipped"};return{id:r.temp_ref,kind:"review-item",resolution:n.resolution,edit:n.edit??null,reason:n.reason??null,...n.supersedeTarget?{supersede_target:n.supersedeTarget}:{},by:Re}})),t.posture==="reconcile"){let r=Xr(H),n=fe(),c=r.adds.length+r.updates.length+r.archives.length,g=n?.state.reconcile?.proposal_id,T={proposal_id:ne,verdicts:{},...g&&g!==ne?{replaces:g}:{}};n&&c>0&&n.save({reconcile:{...T,pending:!0}});let b=await Zr({store:e.store,ctx:Vt(e.store,$.session_id,e.credentials,{reservedEventIds:ut,probe:e.probe,runAuth:e.auth,similarity:e.similarity}),graph:_,sid:$.session_id,proposalId:ne,proposal:H,by:Re,durable:Q,...e.matchUnreviewed?{matchUnreviewed:!0}:{}});b.ok||e.out("note: the unchanged-match evidence attach did not land this run \u2014 the held changeset is unaffected; re-run reconcile to refresh it"),b.skippedAttach>0&&e.out(u.text("note.evidence_not_attached",{count:b.skippedAttach})),n&&c>0&&(b.ok&&n.save({reconcile:T}),he+=c,Ie=!0,Ge=n.state.sid,e.out(`held: ${c} change(s) from ${s.source_id} await your verdicts \u2014 nothing from the changeset committed`),e.emit?.({type:"held",source_id:s.source_id,count:c,reason:"reconcile"})),c===0&&m&&!m.handle.state.reconcile&&s.source_id in m.handle.state.read_basis&&(i(x),m.handle.complete({ended:"complete"}),e.out(`session ${t.resume} complete`),e.emit?.({type:"session_complete",sid:t.resume,source_id:s.source_id}),m=null,S=null);continue}if((Ae||t.trust==="hold")&&fe()&&H.use_cases.some(r=>r.matches_existing==null)){mt(s,H.use_cases,Ae?"degraded":"trust_hold");continue}let vr=Vt(e.store,$.session_id,e.credentials,{reservedEventIds:ut,probe:e.probe,runAuth:e.auth,similarity:e.similarity}),wr=r=>{if(r.degradedProbe&&fe()!==null&&H.use_cases.some(c=>c.matches_existing==null))return{result:{degradedHold:!0},record:null};let n=Ot({store:e.store,graph:r.graph,scope:r.scope,proposal:H,proposalId:ne,verdicts:ze,by:Re,autoName:!0,allowStaleBasis:!0,eventIds:r.eventIds("extract",1),...Q?{sid:r.sid}:{},probeHits:r.probeHits,...e.matchUnreviewed?{matchUnreviewed:!0}:{}});return n.errors!==null?{errors:n.errors}:{result:n,record:n.record}},yr=ve;ve=null;let br={...Ut(H,_),...yr?{eventIds:[yr]}:{}},W=await rt(vr,br,wr);if(!W.ok&&W.kind==="drifted"){if(!await e.confirmStale(`the context changed while you reviewed (${W.asks.map(n=>n.detail).join("; ")}) \u2014 commit against the new head anyway?`)){e.out("aborted: proposal not committed"),e.emit?.({type:"error",source_id:s.source_id,message:"aborted: proposal not committed",code:"STALE_BASIS"}),V(s.source_id);continue}W=await rt(vr,{...br,sourcePins:[]},wr)}e.similarity&&st(e.similarity,A);let St=W.ok&&"result"in W?W.result:null;if(St!==null&&"degradedHold"in St){lt(),mt(s,H.use_cases,"degraded");continue}let Oe=St??(W.ok?{record:null,errors:null}:{record:null,errors:W.kind==="validation"?W.errors:W.kind==="contended"?[{code:W.err.code,detail:`a use-case this proposal touches is held by ${W.err.holder?.owner_sid??"another session"} \u2014 try again when it frees`}]:[{code:"UNSETTLED",detail:"concurrent activity kept moving the store \u2014 retry when quieter"}]});if(Oe.errors){A("commit_error_details",{errors:Oe.errors.map(r=>({code:r.code,detail:r.detail}))},$.session_id),e.out(`\u2717 commit failed \u2014 ${Oe.errors.map(r=>r.code).join(", ")} (details: ${B})`),e.emit?.({type:"error",source_id:s.source_id,message:`error: commit failed: ${Oe.errors.map(r=>`${r.code}: ${r.detail}`).join("; ")}`,code:"COMMIT_FAILED"}),V(s.source_id);continue}let Ys=new Date().toISOString();for(let r of H.use_cases){let n=ze.get(r.temp_ref)??{resolution:"skipped"};for(let c of Or({ts:Ys,command:"context extract",id:r.temp_ref,by:Re},n.resolution))e.store.signals().append(c)}let ie=Oe.record;ie.event_ids?.length&&S?.markApplied(ie.event_ids);let kt=new Map(ie.review.map(r=>[r.id,r.resolution])),Et=[...kt.values()].filter(r=>r==="approved"||r==="edited").length,Ke=[...kt.values()].filter(r=>r==="rejected").length,Pe=ie.nodes.filter(r=>!kt.has(r.cid)).length,$t=ie.supersessions.filter(r=>r.kind==="node"&&r.new!==r.old).length;A("commit",{trusted:Et,derived:Pe,archived:Ke},$.session_id),e.out(`saved ${Et+Pe} use-case(s)`+(Pe>0?` \xB7 ${Pe} awaiting review`:"")+(Ke>0?` \xB7 ${Ke} archived`:"")+($t>0?` \xB7 ${$t} superseded`:""));{let r=ie.review.filter(n=>n.kind==="pending_update");r.length>0&&(e.out(`${r.length} update(s) held for review`),e.emit?.({type:"update_held",count:r.length,targets:r.map(n=>n.id)}))}w.assumedDefaults&&e.out(`assumed: ${w.assumedDefaults} default(s) auto-taken (assumed)`),e.emit?.({type:"commit",source_id:s.source_id,proposal_id:ne,trusted:Et,derived:Pe,archived:Ke,superseded:$t,assumed:w.assumedDefaults??0,evidence_matched:Math.max(0,H.use_cases.length-ie.nodes.length),minted:ie.nodes.map(r=>{let n=ie.names?.find(c=>c.cid===r.cid)?.slug;return{cid:r.cid,...n?{logical_id:n}:{}}})}),m&&s.source_id in m.handle.state.read_basis&&(i(x),m.handle.complete({ended:"complete"}),e.out(`session ${t.resume} complete`),e.emit?.({type:"session_complete",sid:t.resume,source_id:s.source_id}),v?.event("ASR_SESSION_COMPLETE",{duration_ms:Date.now()-Date.parse(m.handle.state.created_at),credits_total:f}),m=null,S=null)}if(S){let x=S.state.ingest_schedule??[];x.some(s=>s.status==="pending")&&S.save({ingest_schedule:x.map(s=>s.status==="pending"?{...s,status:"skipped",note:u.text("note.not_reached",{})}:s)})}rr=!0}finally{if(v?.setRunTotals?.({work_items_total:U.length,work_items_failed:ae.length}),Ae&&v?.event("ASR_EMBED_DEGRADED",{held:tr}),m?.handle.release(),j&&!Fe&&!rr){let i=j.state.checkpoint;if(i)e.out(u.text("note.session_kept",{verb:"extract",sid:j.state.sid,mode:p,seq:i.seq,ts:i.ts})),j.release();else{try{j.complete(a())}catch{j.release()}Yt()}j=null}}if(G){let i=e.chat?.state.ledger.filter(L=>L.kind==="answer"&&L.receipt.form==="assumed").length??0,f=er+i,k=e.chat?.state.credits?.total;e.onSummary?.({state:"complete",facts:[`saved ${se} use-case${se===1?"":"s"} across ${U.length} source${U.length===1?"":"s"}`,...f>0?[`${f} assumed default(s)`]:[],...k!==void 0?[`credits used: ${k.toFixed(1)}`]:[]],tracePath:B})}if(t.plan||ks(e.store),he>0&&(j||Ge)){Fe=!0;let i=j?.state.sid??Ge,f=Ie?u.command("next.review_held_changeset",{}):u.command("next.resume_session",{verb:"extract",sid:i,mode:p});!G&&!(Ie&&e.reviewsHeld)&&e.out(Ie?u.text("note.changeset_held_for_review",{sid:i,held:he}):u.text("note.held_for_review",{sid:i,mode:p,held:he}));let k=Ie&&p!=="interactive",L=k?u.command("next.show_session",{sid:i}):null;if(e.emit?.({type:"session_paused",sid:i,...k?f!==null?{held_review:{cmd:f,needs:"tty"}}:{}:f!==null?{resume:f}:{},...L!==null?{next:[{cmd:L,why:"shows the session and the changeset it holds; its verdicts are given in a terminal",title:"Show the held session"}]}:{},held:he}),G){let x=e.chat?.state.credits?.total;e.onSummary?.({state:"paused",reason:"held for review",facts:[`${he} held item(s) await your review`,...x!==void 0?[`credits used: ${x.toFixed(1)}`]:[]],...f!==null?{resume:f}:{},tracePath:B})}return j?.release(),3}return ae.length>0&&e.out(u.text("note.sources_failed",{failed:ae.length,total:U.length,sources:ae.join(", ")})),Qt(ae.length>0?h.failedRecorded():y()),ae.length>0?1:0}export{Vt as a,hn as b,Hs as c,gn as d,Xs as e,_n as f,Fs as g,vn as h,Ci as i};
@@ -1,7 +1,7 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{e as C,f as y}from"./chunk-Z36KVIRR.js";import{a as $,g as x,h as g,k as E}from"./chunk-Q4JV4U65.js";import{d as k}from"./chunk-NHGPMYM3.js";import{e as w}from"./chunk-SB26HQO7.js";import{b as h}from"./chunk-VZ7KXRXB.js";import{a as P}from"./chunk-ZCBOHWN3.js";import{a as v}from"./chunk-TM45NPWL.js";import{promises as j}from"fs";import{basename as H,resolve as Z}from"path";import{createHash as J}from"crypto";import{promises as R}from"fs";import{basename as N,extname as O,resolve as B}from"path";var M=64*1024,A=100,Y=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;function K(t){try{let i=h(t);return!i||typeof i!="object"?{gateCount:0}:{id:i.policy,gateCount:Array.isArray(i.gates)?i.gates.length:0}}catch{return{gateCount:0}}}function _(t,i,r){if(t.length>M)return{ok:!1,kind:"invalid",message:`policy ${i} is ${t.length} bytes, over the 64 KB limit`};let o=t.toString("utf8"),e=K(o);if(e.gateCount>A)return{ok:!1,kind:"invalid",message:`policy ${i} has ${e.gateCount} gates, over the ${A} limit`};let n=r;if(typeof e.id=="string"&&e.id.length>0){if(!Y.test(e.id))return{ok:!1,kind:"invalid",message:`policy id "${e.id}" in ${i} must start with a letter or digit and use only letters, digits, '.', '_' and '-' (at most 128)`};n=e.id}return{ok:!0,policy:{source:i,name:n,content:o,sha256:J("sha256").update(t).digest("hex"),gateCount:e.gateCount}}}function U(t){let i=new Set;for(let r of t){if(i.has(r.name))return{ok:!1,kind:"invalid",message:`two policies are named "${r.name}" \u2014 each --policy and --policy-id needs its own policy id`};i.add(r.name)}return null}async function b(t,i){return m({files:t,ids:[]},{cwd:i})}async function m(t,i){let r=[];for(let o of t.files){let e=B(i.cwd,o),n;try{n=await R.readFile(e)}catch(u){return{ok:!1,kind:"io",message:`cannot read policy ${o}: ${u.message}`}}let s=_(n,o,N(e,O(e)));if(!s.ok)return s;r.push({path:e,...s.policy})}for(let o of t.ids){let e=`policy-id ${o}`;if(!i.fetchPolicy)return{ok:!1,kind:"io",message:`cannot fetch ${e}: not signed in to Test Manager`};let n;try{n=await i.fetchPolicy(o)}catch(u){return{ok:!1,kind:"io",message:`cannot fetch ${e}: ${u.message}`}}let s=_(Buffer.from(n.content,"utf8"),e,o);if(!s.ok)return s;if(s.policy.sha256!==n.sha256.toLowerCase())return{ok:!1,kind:"invalid",message:`${e}: Test Manager's content does not match its sha256`};r.push({...s.policy,uid:n.uid,version:n.version})}return U(r)??{ok:!0,policies:r}}var p=(t,i)=>`${i.location||t}: ${i.message} (${i.code})${i.hint?` \u2014 ${i.hint}`:""}`;async function re(t,i){let r=await m(t,{cwd:i.cwd,fetchPolicy:i.fetchPolicy});if(!r.ok)return{ok:!1,message:r.message};let o=i.lint??g,e=[],n=[];for(let s of r.policies){let u;try{u=await o(s.content,{source:s.source,catalogYaml:i.catalogYaml})}catch(c){return{ok:!1,message:`cannot lint policy ${s.source}: ${c.message}`}}for(let c of u)(c.severity==="error"?e:n).push(p(s.source,c))}return e.length?{ok:!1,message:`invalid policy:
2
+ import{e as C,f as y}from"./chunk-Z36KVIRR.js";import{a as $,g as x,h as g,k as E}from"./chunk-Q4JV4U65.js";import{d as k}from"./chunk-FHULYIG3.js";import{e as w}from"./chunk-SB26HQO7.js";import{b as h}from"./chunk-VZ7KXRXB.js";import{a as P}from"./chunk-V24LUINK.js";import{a as v}from"./chunk-JYH7CTF7.js";import{promises as j}from"fs";import{basename as H,resolve as Z}from"path";import{createHash as J}from"crypto";import{promises as R}from"fs";import{basename as N,extname as O,resolve as B}from"path";var M=64*1024,A=100,Y=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;function K(t){try{let i=h(t);return!i||typeof i!="object"?{gateCount:0}:{id:i.policy,gateCount:Array.isArray(i.gates)?i.gates.length:0}}catch{return{gateCount:0}}}function _(t,i,r){if(t.length>M)return{ok:!1,kind:"invalid",message:`policy ${i} is ${t.length} bytes, over the 64 KB limit`};let o=t.toString("utf8"),e=K(o);if(e.gateCount>A)return{ok:!1,kind:"invalid",message:`policy ${i} has ${e.gateCount} gates, over the ${A} limit`};let n=r;if(typeof e.id=="string"&&e.id.length>0){if(!Y.test(e.id))return{ok:!1,kind:"invalid",message:`policy id "${e.id}" in ${i} must start with a letter or digit and use only letters, digits, '.', '_' and '-' (at most 128)`};n=e.id}return{ok:!0,policy:{source:i,name:n,content:o,sha256:J("sha256").update(t).digest("hex"),gateCount:e.gateCount}}}function U(t){let i=new Set;for(let r of t){if(i.has(r.name))return{ok:!1,kind:"invalid",message:`two policies are named "${r.name}" \u2014 each --policy and --policy-id needs its own policy id`};i.add(r.name)}return null}async function b(t,i){return m({files:t,ids:[]},{cwd:i})}async function m(t,i){let r=[];for(let o of t.files){let e=B(i.cwd,o),n;try{n=await R.readFile(e)}catch(u){return{ok:!1,kind:"io",message:`cannot read policy ${o}: ${u.message}`}}let s=_(n,o,N(e,O(e)));if(!s.ok)return s;r.push({path:e,...s.policy})}for(let o of t.ids){let e=`policy-id ${o}`;if(!i.fetchPolicy)return{ok:!1,kind:"io",message:`cannot fetch ${e}: not signed in to Test Manager`};let n;try{n=await i.fetchPolicy(o)}catch(u){return{ok:!1,kind:"io",message:`cannot fetch ${e}: ${u.message}`}}let s=_(Buffer.from(n.content,"utf8"),e,o);if(!s.ok)return s;if(s.policy.sha256!==n.sha256.toLowerCase())return{ok:!1,kind:"invalid",message:`${e}: Test Manager's content does not match its sha256`};r.push({...s.policy,uid:n.uid,version:n.version})}return U(r)??{ok:!0,policies:r}}var p=(t,i)=>`${i.location||t}: ${i.message} (${i.code})${i.hint?` \u2014 ${i.hint}`:""}`;async function re(t,i){let r=await m(t,{cwd:i.cwd,fetchPolicy:i.fetchPolicy});if(!r.ok)return{ok:!1,message:r.message};let o=i.lint??g,e=[],n=[];for(let s of r.policies){let u;try{u=await o(s.content,{source:s.source,catalogYaml:i.catalogYaml})}catch(c){return{ok:!1,message:`cannot lint policy ${s.source}: ${c.message}`}}for(let c of u)(c.severity==="error"?e:n).push(p(s.source,c))}return e.length?{ok:!1,message:`invalid policy:
3
3
  ${e.join(`
4
- `)}`}:{ok:!0,policies:r.policies,warnings:n}}function L(t,i={}){let r=null;return async o=>{r??=X(t,i);let e=await(await r).getPolicy(o);return{uid:e.uid,version:e.version,content:e.content,sha256:e.sha256}}}async function X(t,i){let{resolveTmsBasicAuth:r,formatAuthResolutionError:o}=await import("./list-commands-OFRRBU3D.js"),e=t.profile??new v().getActiveProfile()??"default",n=await(i.resolveAuth??r)(e,t.env,{username:t.username,accessKey:t.accessKey});if(!n.ok)throw new Error(o(e,t.env,n).message.replace(/^error: /,"").trim());let s=P(t.env).tmsBaseUrl;return(i.makeClient??((u,c,a)=>new w(u,c,a)))(s,n.creds.username,n.creds.access_key)}var D={pass:0,fail:1,errored:3};function F(t){let i=t.some(r=>r.result==="errored")?"errored":t.some(r=>r.result==="fail")?"fail":"pass";return{result:i,exit_code:D[i]}}function z(t){return{result:"errored",exit_code:D.errored,verdicts:[],files:[],error:t}}function G(t){return`${t}.verdicts`}function de(t,i){return t!==0||!i?t:i.exit_code}async function T(t,i,r={}){let o;try{o=await(r.judge??x)(t,i.map(e=>({content:e.content,path:e.path})))}catch(e){let n=e,s=(n.problems??[]).flatMap(c=>c.diagnostics.map(a=>`${c.source} ${a.location}: ${a.message} (${a.code})`)),u=s.length?`${n.message}: ${s.join("; ")}`:n.message;return{...z(u),...n.code==="USAGE"?{usage:!0}:{}}}try{let e=await(r.write??E)(o,G(t));return{...F(o),verdicts:o,files:e}}catch(e){return{...F(o),verdicts:o,files:[],filesError:e.message}}}function I(t,i){return{type:"verdict",evidence_id:i,result:t.result,exit_code:t.exit_code,policies:t.verdicts.map((r,o)=>({id:r.policy.id,sha256:r.policy.sha256,result:r.result,exit_code:r.exit_code,counts:{total:r.gates.length,failed:r.gates.filter(e=>e.status==="fail").length,warned:r.gates.filter(e=>e.status==="warn").length,errored:r.gates.filter(e=>e.status==="errored").length},failed_gate_ids:r.gates.filter(e=>e.status==="fail").map(e=>e.id),errored_gate_ids:r.gates.filter(e=>e.status==="errored").map(e=>e.id),...r.error?{error:r.error}:{},...t.files[o]!==void 0?{file:t.files[o]}:{}})),...t.error!==void 0?{error:t.error}:{},...t.filesError!==void 0?{files_error:t.filesError}:{}}}function S(t){if(t.error!==void 0)return`verdict: errored \u2014 ${t.error}`;let i=t.verdicts.map(o=>{let e=o.gates.filter(s=>s.status==="fail"||s.status==="errored").map(s=>s.id),n=o.error?o.error.message:e.join(", ");return`${o.policy.id} ${o.result}${n?` (${n})`:""}`}),r=`verdict: ${t.result} \u2014 ${i.join(", ")}`;return t.filesError===void 0?r:`${r}
4
+ `)}`}:{ok:!0,policies:r.policies,warnings:n}}function L(t,i={}){let r=null;return async o=>{r??=X(t,i);let e=await(await r).getPolicy(o);return{uid:e.uid,version:e.version,content:e.content,sha256:e.sha256}}}async function X(t,i){let{resolveTmsBasicAuth:r,formatAuthResolutionError:o}=await import("./list-commands-QFTIQE6Q.js"),e=t.profile??new v().getActiveProfile()??"default",n=await(i.resolveAuth??r)(e,t.env,{username:t.username,accessKey:t.accessKey});if(!n.ok)throw new Error(o(e,t.env,n).message.replace(/^error: /,"").trim());let s=P(t.env).tmsBaseUrl;return(i.makeClient??((u,c,a)=>new w(u,c,a)))(s,n.creds.username,n.creds.access_key)}var D={pass:0,fail:1,errored:3};function F(t){let i=t.some(r=>r.result==="errored")?"errored":t.some(r=>r.result==="fail")?"fail":"pass";return{result:i,exit_code:D[i]}}function z(t){return{result:"errored",exit_code:D.errored,verdicts:[],files:[],error:t}}function G(t){return`${t}.verdicts`}function de(t,i){return t!==0||!i?t:i.exit_code}async function T(t,i,r={}){let o;try{o=await(r.judge??x)(t,i.map(e=>({content:e.content,path:e.path})))}catch(e){let n=e,s=(n.problems??[]).flatMap(c=>c.diagnostics.map(a=>`${c.source} ${a.location}: ${a.message} (${a.code})`)),u=s.length?`${n.message}: ${s.join("; ")}`:n.message;return{...z(u),...n.code==="USAGE"?{usage:!0}:{}}}try{let e=await(r.write??E)(o,G(t));return{...F(o),verdicts:o,files:e}}catch(e){return{...F(o),verdicts:o,files:[],filesError:e.message}}}function I(t,i){return{type:"verdict",evidence_id:i,result:t.result,exit_code:t.exit_code,policies:t.verdicts.map((r,o)=>({id:r.policy.id,sha256:r.policy.sha256,result:r.result,exit_code:r.exit_code,counts:{total:r.gates.length,failed:r.gates.filter(e=>e.status==="fail").length,warned:r.gates.filter(e=>e.status==="warn").length,errored:r.gates.filter(e=>e.status==="errored").length},failed_gate_ids:r.gates.filter(e=>e.status==="fail").map(e=>e.id),errored_gate_ids:r.gates.filter(e=>e.status==="errored").map(e=>e.id),...r.error?{error:r.error}:{},...t.files[o]!==void 0?{file:t.files[o]}:{}})),...t.error!==void 0?{error:t.error}:{},...t.filesError!==void 0?{files_error:t.filesError}:{}}}function S(t){if(t.error!==void 0)return`verdict: errored \u2014 ${t.error}`;let i=t.verdicts.map(o=>{let e=o.gates.filter(s=>s.status==="fail"||s.status==="errored").map(s=>s.id),n=o.error?o.error.message:e.join(", ");return`${o.policy.id} ${o.result}${n?` (${n})`:""}`}),r=`verdict: ${t.result} \u2014 ${i.join(", ")}`;return t.filesError===void 0?r:`${r}
5
5
  \u26A0 verdict files not written: ${t.filesError}`}function ue(t,i){return i.verdicts.length===0?{}:{policies:t.map(r=>({name:r.name,content:r.content,sha256:r.sha256})),verdicts:i.verdicts}}async function $e(t,i,r=process.cwd()){let o=await y(t,r);if(!o){let n=`evidence: no pack found for "${t}"`;return i.json?console.log(JSON.stringify({valid:!1,error:"not_found",target:t})):console.error(n),2}let e=await $(o,i.profile??"L1");return i.json?console.log(JSON.stringify({valid:e.valid,status:e.status,diagnostics:e.diagnostics})):console.log(`evidence: ${e.valid?"valid":"INVALID"} (${i.profile??"L1"}, status ${e.status})`),e.valid?0:1}async function xe(t,i,r=process.cwd(),o={}){let e=o.out??(d=>process.stdout.write(d+`
6
6
  `)),n=o.err??(d=>process.stderr.write(d+`
7
7
  `)),s=await(o.catalog??k(i.env??"prod")),u=o.lint??g,c=[];for(let d of t){let l=await b([d],r);if(!l.ok&&l.kind==="io")return n(`evidence lint-policy: ${l.message}`),2;let f;if(l.ok)try{f=await u(l.policies[0].content,{source:d,catalogYaml:s.yaml})}catch(V){return n(`evidence lint-policy: cannot lint ${d}: ${V.message}`),2}else f=[{code:"policy.limits",severity:"error",location:"",message:l.message}];c.push({path:d,diagnostics:f})}let a=c.every(d=>d.diagnostics.every(l=>l.severity!=="error"));if(i.json)e(JSON.stringify({valid:a,files:c}));else for(let d of c){d.diagnostics.length===0&&e(`${d.path}: ok`);for(let l of d.diagnostics)e(`${l.severity}: ${p(d.path,l)}`)}return a?0:1}async function q(t,i=process.cwd()){if(t!=="latest"){let o=Z(i,t);return await j.stat(o).then(()=>!0,()=>!1)?o:y(t,i)}let r=null;for(let o of await C(i)){let e=await j.stat(o).catch(()=>null);e?.isFile()&&(!r||e.mtimeMs>r.mtime)&&(r={path:o,mtime:e.mtimeMs})}return r?.path??null}async function Ee(t,i,r=process.cwd(),o={}){let e=o.out??(l=>process.stdout.write(l+`