@testmuai/kane-cli 0.10.0-rc.3 → 0.10.2

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 (421) hide show
  1. package/dist/ChatSurface-FIYDTZSI.js +2 -0
  2. package/dist/{ChromeProfilePicker-M4WXOB5O.js → ChromeProfilePicker-Q6FIGVYU.js} +1 -1
  3. package/dist/{CliFeedbackPrompt-6MJA7DF6.js → CliFeedbackPrompt-2NV2G65E.js} +1 -1
  4. package/dist/{CliUploadProgress-6NLS7XHH.js → CliUploadProgress-JZ5FXODE.js} +1 -1
  5. package/dist/{ConfigView-O4WKZ5PU.js → ConfigView-TZ4YINOE.js} +1 -1
  6. package/dist/EvidenceViewOffer-LKPN5BHX.js +2 -0
  7. package/dist/FolderPicker-H5K74PCH.js +2 -0
  8. package/dist/InfoBox-DNSOAK5L.js +2 -0
  9. package/dist/{LinksBox-DXP66H3H.js → LinksBox-32TZOANP.js} +1 -1
  10. package/dist/{ProfilesView-TWOY5PVC.js → ProfilesView-UC4MPM54.js} +1 -1
  11. package/dist/ProjectPicker-ZJ5RW6XL.js +2 -0
  12. package/dist/SaveSessionPrompt-F327WC7A.js +2 -0
  13. package/dist/SingleShotApp-OMLRYOSI.js +2 -0
  14. package/dist/{SummaryBox-IA2KS6GT.js → SummaryBox-XGFO5X76.js} +1 -1
  15. package/dist/TestMdRunView-ZZ77QTAQ.js +2 -0
  16. package/dist/TestrunEvidenceTable-G7MPF55X.js +2 -0
  17. package/dist/{WhoamiView-SNL75TEF.js → WhoamiView-4XIJXMTU.js} +1 -1
  18. package/dist/{app-download-UI4ABEIX.js → app-download-XEDO3EMV.js} +1 -1
  19. package/dist/{assurance-job-FFSSS4XV.js → assurance-job-MD65GQLC.js} +1 -1
  20. package/dist/{auth-7Z54TMQQ.js → auth-WBIEHHDS.js} +1 -1
  21. package/dist/{binary-THPLXCOD.js → binary-NVYLR36K.js} +1 -1
  22. package/dist/bind-H3ALI2NG.js +2 -0
  23. package/dist/bootstrap-JEVSVPQ2.js +2 -0
  24. package/dist/bridge-2UHJOVLX.js +2 -0
  25. package/dist/{catalog-MYPS2BXY.js → catalog-5UYBWA4W.js} +1 -1
  26. package/dist/catalog-client-VVKV4JKW.js +2 -0
  27. package/dist/{changelog-SU674BVE.js → changelog-FPWJXERY.js} +1 -1
  28. package/dist/chat-committer-ZKEKJA2R.js +2 -0
  29. package/dist/chat-controller-FXRJXUG3.js +2 -0
  30. package/dist/child-JHYENXE7.js +2 -0
  31. package/dist/chunk-226AGYHB.js +87 -0
  32. package/dist/{chunk-MNBGG4H3.js → chunk-23DKB2MT.js} +1 -1
  33. package/dist/{chunk-EECDDDSB.js → chunk-2COXO5LQ.js} +1 -1
  34. package/dist/{chunk-LUR7JFPP.js → chunk-2GEAKFAV.js} +1 -1
  35. package/dist/{chunk-7SY34IIL.js → chunk-2QKBXRLI.js} +1 -1
  36. package/dist/{chunk-AVSMXDTX.js → chunk-2ULYGALF.js} +1 -1
  37. package/dist/{chunk-JNSWKGTB.js → chunk-32HED7X2.js} +1 -1
  38. package/dist/{chunk-GRURFGBP.js → chunk-32MFECUA.js} +1 -1
  39. package/dist/{chunk-MYVKUJGS.js → chunk-35BG2EMW.js} +1 -1
  40. package/dist/{chunk-3GXN6VF6.js → chunk-3KY7HHQU.js} +1 -1
  41. package/dist/{chunk-7NPTL66J.js → chunk-3V4J65GN.js} +1 -1
  42. package/dist/{chunk-457Y5TEC.js → chunk-3YIA3DSL.js} +1 -1
  43. package/dist/{chunk-36N3EHW5.js → chunk-44SIFDNY.js} +1 -1
  44. package/dist/{chunk-MEKPGQAM.js → chunk-45NM23EQ.js} +2 -2
  45. package/dist/{chunk-I2MC6VVX.js → chunk-4C7WVQOD.js} +1 -1
  46. package/dist/{chunk-TU42YZOJ.js → chunk-4HARMERK.js} +1 -1
  47. package/dist/{chunk-ICLUC44J.js → chunk-4HYPMGDF.js} +1 -1
  48. package/dist/{chunk-7KX2BHKG.js → chunk-4KCYNP2K.js} +1 -1
  49. package/dist/{chunk-IJ2AHSWW.js → chunk-4LGQHTXM.js} +1 -1
  50. package/dist/{chunk-ETZMFRD6.js → chunk-4NEPHIAO.js} +1 -1
  51. package/dist/{chunk-3E4ZO73O.js → chunk-54NJJVG5.js} +1 -1
  52. package/dist/{chunk-734ORT6O.js → chunk-5F44KH3R.js} +1 -1
  53. package/dist/{chunk-E6KSRQXL.js → chunk-5F5IVART.js} +1 -1
  54. package/dist/{chunk-EBPRPNSA.js → chunk-5KJU4MG4.js} +1 -1
  55. package/dist/{chunk-JZP3Y4ZM.js → chunk-5MFPQYW3.js} +1 -1
  56. package/dist/{chunk-QENCC2ZS.js → chunk-5WLXAQ4H.js} +1 -1
  57. package/dist/{chunk-RFEON5GN.js → chunk-5XVWT6UK.js} +1 -1
  58. package/dist/{chunk-W4QSZNMB.js → chunk-6CS23F3E.js} +1 -1
  59. package/dist/{chunk-DZOYYWOW.js → chunk-6JUS2ULI.js} +1 -1
  60. package/dist/chunk-6K5BEEAJ.js +2 -0
  61. package/dist/{chunk-4QFTHUJA.js → chunk-6LEHGRRG.js} +1 -1
  62. package/dist/{chunk-LSDJOVWW.js → chunk-6SD4XTYC.js} +1 -1
  63. package/dist/{chunk-TW5AA5A7.js → chunk-6SWHEBPR.js} +1 -1
  64. package/dist/{chunk-URH4FX3H.js → chunk-6YBH3WUW.js} +1 -1
  65. package/dist/{chunk-ZAFJQ3SM.js → chunk-73HMW2WA.js} +1 -1
  66. package/dist/{chunk-NXAJBSIF.js → chunk-75FF7J5R.js} +1 -1
  67. package/dist/{chunk-P3JXJ4BW.js → chunk-7DLDADQR.js} +1 -1
  68. package/dist/{chunk-7NCJMWFX.js → chunk-7LYLJ75Z.js} +1 -1
  69. package/dist/chunk-7O2FIZB7.js +9 -0
  70. package/dist/chunk-7PCLHURF.js +101 -0
  71. package/dist/{chunk-PUVMC4PX.js → chunk-7V34ZMMS.js} +1 -1
  72. package/dist/{chunk-AEWNWAXW.js → chunk-7XJNYLQW.js} +2 -2
  73. package/dist/{chunk-WEIPY3CI.js → chunk-7ZR5CQY3.js} +1 -1
  74. package/dist/{chunk-2DYHAP4E.js → chunk-A474TUCE.js} +1 -1
  75. package/dist/chunk-A4ZV2SHL.js +5 -0
  76. package/dist/chunk-A7IMHUFY.js +27 -0
  77. package/dist/{chunk-XLEGGC4Y.js → chunk-ABMM37L2.js} +1 -1
  78. package/dist/{chunk-NIVFEACM.js → chunk-AUSLHNXQ.js} +1 -1
  79. package/dist/{chunk-YPFQ4UGF.js → chunk-B226SFOV.js} +1 -1
  80. package/dist/{chunk-DJC7NTLA.js → chunk-B57ZRHEQ.js} +1 -1
  81. package/dist/{chunk-CGITGJ3I.js → chunk-BHQIH2FE.js} +1 -1
  82. package/dist/{chunk-FWUPJORV.js → chunk-BJT6PZXL.js} +1 -1
  83. package/dist/{chunk-VX657KIK.js → chunk-C6P6YUCR.js} +1 -1
  84. package/dist/chunk-CB344EDO.js +2 -0
  85. package/dist/chunk-CCOD4GQJ.js +2 -0
  86. package/dist/{chunk-ZFM77AQU.js → chunk-CQDCNP7V.js} +1 -1
  87. package/dist/{chunk-VUFIL5VR.js → chunk-D4QXYAYA.js} +2 -2
  88. package/dist/{chunk-Y7E5L42F.js → chunk-DLP5S3TO.js} +1 -1
  89. package/dist/{chunk-35ECWCCK.js → chunk-DXIQVBMI.js} +1 -1
  90. package/dist/chunk-DXLZCJH5.js +7 -0
  91. package/dist/{chunk-OJ33Q6DU.js → chunk-E4GIGM5V.js} +1 -1
  92. package/dist/{chunk-I4WXALQR.js → chunk-EAWU2TOG.js} +1 -1
  93. package/dist/{chunk-ACMBMZDQ.js → chunk-EEOAU43D.js} +1 -1
  94. package/dist/{chunk-MYZHOBS4.js → chunk-EHB55V23.js} +1 -1
  95. package/dist/{chunk-UYDHOHSZ.js → chunk-ENRFXGID.js} +1 -1
  96. package/dist/{chunk-RTVHJ23A.js → chunk-ET5EK2CM.js} +1 -1
  97. package/dist/{chunk-EF47KRUK.js → chunk-EZMRWXRT.js} +1 -1
  98. package/dist/chunk-FAMQ4DHU.js +2 -0
  99. package/dist/{chunk-C2RUDJ46.js → chunk-FI2DVNRT.js} +1 -1
  100. package/dist/{chunk-AUJSC7PU.js → chunk-FNUGDPTS.js} +1 -1
  101. package/dist/{chunk-VLDCHFXF.js → chunk-FOLUB336.js} +1 -1
  102. package/dist/{chunk-NZ6AV2TA.js → chunk-FYPIF3BE.js} +1 -1
  103. package/dist/{chunk-HHW6MRU3.js → chunk-G4K3TP2I.js} +1 -1
  104. package/dist/{chunk-P2ZQDQDB.js → chunk-GAKBHNC4.js} +1 -1
  105. package/dist/{chunk-DPGOAFKF.js → chunk-GBQ4K25P.js} +1 -1
  106. package/dist/{chunk-O3HHTKZ5.js → chunk-GEZVC4S3.js} +1 -1
  107. package/dist/chunk-GJ7MO2FW.js +9 -0
  108. package/dist/{chunk-EZN7CF45.js → chunk-GJXO6FF7.js} +1 -1
  109. package/dist/{chunk-QDFY5GGO.js → chunk-GLM5UGTF.js} +1 -1
  110. package/dist/{chunk-HK62JVQM.js → chunk-GQARXS6F.js} +1 -1
  111. package/dist/{chunk-I4RVVBG3.js → chunk-GT3JDX5H.js} +1 -1
  112. package/dist/{chunk-YLXWAY7D.js → chunk-GZQAETB2.js} +1 -1
  113. package/dist/{chunk-7HMSMAUG.js → chunk-H4TIVILC.js} +5 -5
  114. package/dist/{chunk-VXGN3IV7.js → chunk-HG2ILWCE.js} +1 -1
  115. package/dist/{chunk-M43WH5DQ.js → chunk-HHOVANJ7.js} +1 -1
  116. package/dist/{chunk-CM4CHYSN.js → chunk-HM6LZ2KM.js} +1 -1
  117. package/dist/{chunk-QDXKEOKI.js → chunk-HNF3PWF3.js} +6 -6
  118. package/dist/{chunk-R7KXAISS.js → chunk-HVOXMCKE.js} +1 -1
  119. package/dist/{chunk-D7U2M26S.js → chunk-HWPWCCEV.js} +1 -1
  120. package/dist/{chunk-XRNQSXOM.js → chunk-HX5OLRKU.js} +2 -2
  121. package/dist/{chunk-4I7YN6YY.js → chunk-HYJVYYAZ.js} +2 -2
  122. package/dist/{chunk-CUXY6KQ2.js → chunk-I52NWH4U.js} +1 -1
  123. package/dist/{chunk-IGEAET7M.js → chunk-IB5WG5YY.js} +1 -1
  124. package/dist/{chunk-LAOTVZHV.js → chunk-IH73ZCBB.js} +1 -1
  125. package/dist/{chunk-TU7TVFBK.js → chunk-IT5JVCZN.js} +1 -1
  126. package/dist/{chunk-54XA5MZH.js → chunk-IZ66FKPC.js} +1 -1
  127. package/dist/{chunk-44B6THYK.js → chunk-JNPFEBUR.js} +1 -1
  128. package/dist/{chunk-RX6776AI.js → chunk-JTNEF5ZP.js} +1 -1
  129. package/dist/{chunk-QBYENBMB.js → chunk-JUVY6PHY.js} +1 -1
  130. package/dist/{chunk-5AKJPYUW.js → chunk-K4K2BGQC.js} +3 -3
  131. package/dist/{chunk-HJMCXSUJ.js → chunk-K75WIRI5.js} +1 -1
  132. package/dist/{chunk-FSYOTRMC.js → chunk-KKLCXRW6.js} +1 -1
  133. package/dist/{chunk-7YT4TTKL.js → chunk-KN7GZWKK.js} +1 -1
  134. package/dist/{chunk-ZTHYAHDN.js → chunk-L3BUPFAQ.js} +4 -4
  135. package/dist/{chunk-7XBNMOH4.js → chunk-LLQWEGXD.js} +1 -1
  136. package/dist/chunk-LTPOMMAB.js +2 -0
  137. package/dist/{chunk-CCP4X75B.js → chunk-LWCP4GLY.js} +1 -1
  138. package/dist/chunk-LXCTV75T.js +12 -0
  139. package/dist/{chunk-RDP7GWSY.js → chunk-LZGAFKYH.js} +1 -1
  140. package/dist/{chunk-3QICDXY5.js → chunk-LZPYIFHZ.js} +1 -1
  141. package/dist/{chunk-3OQW2GTA.js → chunk-M3TFOFUQ.js} +1 -1
  142. package/dist/{chunk-V7USCQWO.js → chunk-M7Y5GGVJ.js} +1 -1
  143. package/dist/{chunk-SMTBOSEJ.js → chunk-MEMXFTLD.js} +1 -1
  144. package/dist/{chunk-D756UWY2.js → chunk-MINDIQET.js} +1 -1
  145. package/dist/{chunk-ZTRRFG52.js → chunk-MP6NCJFE.js} +1 -1
  146. package/dist/{chunk-GXKY5A46.js → chunk-MSYRAPDK.js} +1 -1
  147. package/dist/{chunk-HJLMH7ZM.js → chunk-MUX2A37P.js} +1 -1
  148. package/dist/{chunk-YHFZFV3A.js → chunk-NCP54AIQ.js} +9 -9
  149. package/dist/{chunk-ZU4W2QGM.js → chunk-NVD2MXHQ.js} +1 -1
  150. package/dist/{chunk-FWDUVFS6.js → chunk-O2Y46A3G.js} +17 -17
  151. package/dist/{chunk-XZGEN4NU.js → chunk-O3TXAMFW.js} +1 -1
  152. package/dist/{chunk-YGRULEZY.js → chunk-O5KTMDTH.js} +1 -1
  153. package/dist/{chunk-PAWQ4AKN.js → chunk-OK6NLITG.js} +1 -1
  154. package/dist/{chunk-7AET4JKQ.js → chunk-OKA6FPJM.js} +1 -1
  155. package/dist/{chunk-3YTCKCBG.js → chunk-OVNTCBNS.js} +1 -1
  156. package/dist/{chunk-YQ5C6UDG.js → chunk-P4VFC6HO.js} +1 -1
  157. package/dist/{chunk-LQQNPMOD.js → chunk-PC22QRIY.js} +1 -1
  158. package/dist/{chunk-XQMWHPZI.js → chunk-PEUIHME2.js} +1 -1
  159. package/dist/{chunk-UEE3RZN4.js → chunk-PI7OXS62.js} +1 -1
  160. package/dist/{chunk-D7TKE7LK.js → chunk-POA336CU.js} +1 -1
  161. package/dist/{chunk-WZXPF3BI.js → chunk-PR5EGLEI.js} +1 -1
  162. package/dist/{chunk-YIKF4ERQ.js → chunk-PRBWZXFA.js} +2 -2
  163. package/dist/{chunk-XZYA7DNH.js → chunk-PVN64537.js} +1 -1
  164. package/dist/{chunk-VSVWNRI2.js → chunk-PWNYTIVA.js} +1 -1
  165. package/dist/chunk-Q4JV4U65.js +161 -0
  166. package/dist/{chunk-LUZBGTYB.js → chunk-Q5AKIQIE.js} +1 -1
  167. package/dist/{chunk-6EB5VRAN.js → chunk-QB77LRF4.js} +1 -1
  168. package/dist/{chunk-GQRU3B54.js → chunk-QUNIY6NN.js} +1 -1
  169. package/dist/{chunk-KODJVOCN.js → chunk-QVMXL675.js} +1 -1
  170. package/dist/{chunk-LCSJ7GOG.js → chunk-R6TFRAMZ.js} +1 -1
  171. package/dist/{chunk-4YW767UV.js → chunk-RAVAJZV2.js} +7 -7
  172. package/dist/{chunk-DDZLCAEO.js → chunk-RDAIOJCR.js} +1 -1
  173. package/dist/{chunk-RPRXRKKR.js → chunk-RQKMSNEU.js} +1 -1
  174. package/dist/{chunk-ECPFI75W.js → chunk-RRKYHUOD.js} +1 -1
  175. package/dist/{chunk-3RJHXOZH.js → chunk-S7XCOBYD.js} +1 -1
  176. package/dist/{chunk-Q3C6NDGI.js → chunk-SALZ6WSF.js} +1 -1
  177. package/dist/{chunk-ZFMRQ57Y.js → chunk-SIHX5FW5.js} +1 -1
  178. package/dist/{chunk-FIP5L6LV.js → chunk-SSOUYKVG.js} +1 -1
  179. package/dist/{chunk-TNORODUF.js → chunk-SVIIUKJ2.js} +1 -1
  180. package/dist/{chunk-7RWP4Y3H.js → chunk-T77LTLAD.js} +1 -1
  181. package/dist/{chunk-NLZZLANH.js → chunk-TAY7J5VS.js} +1 -1
  182. package/dist/chunk-TD6GCEIK.js +2 -0
  183. package/dist/{chunk-LKQFG4RW.js → chunk-TM6VLC6V.js} +1 -1
  184. package/dist/{chunk-YAW6JW6D.js → chunk-TMH4TPMB.js} +1 -1
  185. package/dist/{chunk-OFSDB7B4.js → chunk-TU2KPOW2.js} +2 -2
  186. package/dist/{chunk-3BSYOCSW.js → chunk-U2VYTVKV.js} +1 -1
  187. package/dist/{chunk-LIGTP3A3.js → chunk-UCVP7ZY4.js} +1 -1
  188. package/dist/{chunk-RHGW7B5Q.js → chunk-UICJ2KLJ.js} +1 -1
  189. package/dist/chunk-UJLULWSR.js +21 -0
  190. package/dist/{chunk-OCDBTAYS.js → chunk-UMNCM4RJ.js} +2 -2
  191. package/dist/{chunk-WOSANGV6.js → chunk-UWPG5MWM.js} +1 -1
  192. package/dist/{chunk-W6HZF56M.js → chunk-V3OZJO7Y.js} +1 -1
  193. package/dist/{chunk-3F5FMH76.js → chunk-VE4HLIGA.js} +1 -1
  194. package/dist/{chunk-RF37IJNN.js → chunk-W2HRX3DR.js} +1 -1
  195. package/dist/{chunk-NXRF7FFS.js → chunk-W54BX6HC.js} +1 -1
  196. package/dist/{chunk-IZ65ZPWY.js → chunk-W5HFUBXD.js} +1 -1
  197. package/dist/{chunk-HAW5WEKT.js → chunk-WEJR2V7R.js} +1 -1
  198. package/dist/{chunk-F5NHG7VB.js → chunk-X3A4QPA3.js} +1 -1
  199. package/dist/{chunk-AVI5H4UM.js → chunk-X52YIWGG.js} +1 -1
  200. package/dist/{chunk-72RC7JSA.js → chunk-X6FCXBXU.js} +1 -1
  201. package/dist/{chunk-PZA3BSOE.js → chunk-X7S7IGCV.js} +1 -1
  202. package/dist/{chunk-6DZX5HLZ.js → chunk-XCUF5AVM.js} +1 -1
  203. package/dist/{chunk-F22K3RRX.js → chunk-XHFU5TGS.js} +1 -1
  204. package/dist/chunk-XNXJXGVB.js +4 -0
  205. package/dist/{chunk-C62QWG4B.js → chunk-XZ6J3Y2W.js} +1 -1
  206. package/dist/{chunk-JGRXMTME.js → chunk-YDB72F4K.js} +1 -1
  207. package/dist/{chunk-7DFBOVUB.js → chunk-YJAQZMJT.js} +1 -1
  208. package/dist/chunk-YO6SNXBJ.js +2 -0
  209. package/dist/{chunk-AZLNLHUA.js → chunk-Z24SD2EJ.js} +1 -1
  210. package/dist/{chunk-HQ2E2XCU.js → chunk-Z36KVIRR.js} +1 -1
  211. package/dist/{chunk-WAOUE7MP.js → chunk-Z6SI7YNV.js} +1 -1
  212. package/dist/{chunk-6NFOH4AC.js → chunk-ZAQGIC33.js} +1 -1
  213. package/dist/{chunk-6UVIY56J.js → chunk-ZCL7XIVS.js} +1 -1
  214. package/dist/{chunk-UUJIGOEO.js → chunk-ZDCXWEQG.js} +1 -1
  215. package/dist/{chunk-SGPAM5DZ.js → chunk-ZDQYGLCZ.js} +1 -1
  216. package/dist/{chunk-42PALMW2.js → chunk-ZHAMVLQZ.js} +1 -1
  217. package/dist/{chunk-W7FLXW6Q.js → chunk-ZMWTRXFH.js} +1 -1
  218. package/dist/{chunk-KXHJMAZU.js → chunk-ZO3ZAMUU.js} +2 -2
  219. package/dist/{chunk-L5DALV5N.js → chunk-ZZZGTDYE.js} +1 -1
  220. package/dist/commands-R5AYK6XM.js +2 -0
  221. package/dist/{committer-JGY66PFM.js → committer-UO3B3S5Y.js} +1 -1
  222. package/dist/{config-754B73XK.js → config-YMHI3H3Y.js} +1 -1
  223. package/dist/cover-cmd-DVQIGFDY.js +2 -0
  224. package/dist/{credentials-F7DYLVWY.js → credentials-BCR73VGS.js} +1 -1
  225. package/dist/{deps-bundle-PW3WEQJ7.js → deps-bundle-6WLX44OA.js} +1 -1
  226. package/dist/{deps-resolve-SQYVN76L.js → deps-resolve-DSAKPZ3T.js} +1 -1
  227. package/dist/{design-chat-F3OEZPNJ.js → design-chat-YUI2JPO6.js} +1 -1
  228. package/dist/design-committer-7YIPFKMO.js +2 -0
  229. package/dist/design-headless-KIP6R7UV.js +2 -0
  230. package/dist/{design-remote-2BEGCVCX.js → design-remote-XMSHDDUX.js} +2 -2
  231. package/dist/device-env-K7J5NN66.js +2 -0
  232. package/dist/dispatch-BV6XMCN3.js +2 -0
  233. package/dist/{doctor-XY26Z35T.js → doctor-PGTNOMSP.js} +1 -1
  234. package/dist/{docx-convert-6IZO5P5K.js → docx-convert-DO5AQYD3.js} +1 -1
  235. package/dist/{dossier-NROC2MCY.js → dossier-5XKNAK6Q.js} +1 -1
  236. package/dist/evidence-RO3RDZXO.js +2 -0
  237. package/dist/evidence-presentation-LSFOZGLH.js +2 -0
  238. package/dist/evolve-cmd-U2ALVGMT.js +2 -0
  239. package/dist/evolve-remote-K2MCCVMM.js +2 -0
  240. package/dist/{exit-manager-EDHCETUN.js → exit-manager-EGWAZHCR.js} +1 -1
  241. package/dist/{explain-cmd-VYAANFFZ.js → explain-cmd-KNDORU2D.js} +1 -1
  242. package/dist/{explain-cmd-OP5I5W3O.js → explain-cmd-UWK5YVXG.js} +1 -1
  243. package/dist/explore-S2BGQUIF.js +2 -0
  244. package/dist/{explore-context-tty-RZ7D2TBV.js → explore-context-tty-WJHUSP3A.js} +1 -1
  245. package/dist/{explore-entry-EKXJ67BD.js → explore-entry-3EX2T3NS.js} +4 -4
  246. package/dist/{explore-live-2YVRAQZO.js → explore-live-TRY5A2ME.js} +1 -1
  247. package/dist/{explore-run-tty-D47FGPX7.js → explore-run-tty-ZV5XFKZA.js} +2 -2
  248. package/dist/{extract-bind-W2NET364.js → extract-bind-TXUBMK3T.js} +3 -3
  249. package/dist/extract-chat-VPYDGQKO.js +2 -0
  250. package/dist/{extract-cmd-FTFLETOP.js → extract-cmd-YUOYMVF5.js} +2 -2
  251. package/dist/extract-headless-UWTAPOET.js +2 -0
  252. package/dist/{feeder-NY45UFJK.js → feeder-NGWIPZ26.js} +1 -1
  253. package/dist/folder-flags-WV7UV3JG.js +2 -0
  254. package/dist/gaps-cmd-PFV3FZCM.js +3 -0
  255. package/dist/gate-7ALXLCNB.js +2 -0
  256. package/dist/gate-NB5CJMTN.js +2 -0
  257. package/dist/{generate-headless-RURIEKVS.js → generate-headless-KMBBZTLS.js} +2 -2
  258. package/dist/hold-passthrough-JGHWMYDM.js +2 -0
  259. package/dist/impact-cmd-PW33L5RF.js +11 -0
  260. package/dist/index.js +4150 -180
  261. package/dist/ingest-ZHHHBUXR.js +2 -0
  262. package/dist/{ingest-cmd-4G2AK4Y2.js → ingest-cmd-MXYILQLV.js} +3 -3
  263. package/dist/ingest-remote-2EEJP6ML.js +2 -0
  264. package/dist/install-7J34AYB6.js +2 -0
  265. package/dist/{interactive-bind-SI2ZS55Q.js → interactive-bind-FDWJUTI6.js} +4 -4
  266. package/dist/{interactive-remote-J56EWJGA.js → interactive-remote-O2Q2FNOH.js} +2 -2
  267. package/dist/lane-CNGO7LH5.js +2 -0
  268. package/dist/lattice-auth-TXNDLHM6.js +2 -0
  269. package/dist/{lifecycle-cmd-HJ37LTXE.js → lifecycle-cmd-GFHDBRXX.js} +1 -1
  270. package/dist/{list-cmd-6XL2FYLQ.js → list-cmd-RR75PMPE.js} +1 -1
  271. package/dist/list-commands-3QGZWJ5P.js +2 -0
  272. package/dist/{list-remote-LXPQNXYN.js → list-remote-AA3VSWOI.js} +1 -1
  273. package/dist/{locks-cmd-JJ2QNTNY.js → locks-cmd-AZKCSGHI.js} +1 -1
  274. package/dist/{logical-ids-RXAQJZ3T.js → logical-ids-74PLU3VR.js} +1 -1
  275. package/dist/login-flow-ZQ6UFTS2.js +2 -0
  276. package/dist/{maintenance-cmd-BXXHP36K.js → maintenance-cmd-OHGVARQ2.js} +1 -1
  277. package/dist/{mobile-prompts-CECJ5UY2.js → mobile-prompts-FZRKLLTN.js} +1 -1
  278. package/dist/{objective-variable-gate-3Z7DNVVC.js → objective-variable-gate-V5HHFOUS.js} +1 -1
  279. package/dist/{onboarding-PDVYMTY5.js → onboarding-NXGMV3VG.js} +1 -1
  280. package/dist/open-provider-XDJKT3W3.js +2 -0
  281. package/dist/pdf-convert-YB6PJFMI.js +2 -0
  282. package/dist/persist-recorded-session-INFN4JZT.js +3 -0
  283. package/dist/phase-seed-ZZSJME7M.js +2 -0
  284. package/dist/pipeline-MVZRI6YZ.js +2 -0
  285. package/dist/policy-commands-3YJ6YCDN.js +8 -0
  286. package/dist/prepare-target-DII5WZCX.js +2 -0
  287. package/dist/{pull-cmd-UPFQYUND.js → pull-cmd-XZN53XFZ.js} +1 -1
  288. package/dist/pull-route-R33BVADE.js +2 -0
  289. package/dist/readmodel-TRV4E3MW.js +2 -0
  290. package/dist/real-device-run-DGENHGUV.js +2 -0
  291. package/dist/{reconcile-cmd-JBH365JL.js → reconcile-cmd-KFPRCCJB.js} +4 -4
  292. package/dist/reconcile-deps-UDQBWSLE.js +2 -0
  293. package/dist/{reconcile-remote-BCX6SWFC.js → reconcile-remote-6WISFGRG.js} +2 -2
  294. package/dist/{recording-banner-YKBAL6UB.js → recording-banner-XOX2CDCF.js} +1 -1
  295. package/dist/registry-NV3EMDMK.js +2 -0
  296. package/dist/remote-entry-BCTFT643.js +2 -0
  297. package/dist/remote-mode-4HN27MD4.js +4 -0
  298. package/dist/{remote-words-YVB66R3F.js → remote-words-LFDYKIZ7.js} +1 -1
  299. package/dist/{require-project-folder-MLMEQJYP.js → require-project-folder-ZK4JJCDB.js} +1 -1
  300. package/dist/{resolve-run-intent-PC7TQZUL.js → resolve-run-intent-LYLVNNDZ.js} +1 -1
  301. package/dist/{resolver-EID34LQE.js → resolver-RMHGGYRP.js} +1 -1
  302. package/dist/revert-QKHPCRT6.js +2 -0
  303. package/dist/{review-cmd-EUHFLFMY.js → review-cmd-UGF2FC5Y.js} +1 -1
  304. package/dist/run-CSYGVV3D.js +2 -0
  305. package/dist/run-YUHHD54J.js +2 -0
  306. package/dist/{run-channel-63SVP5OI.js → run-channel-IIIYXOIW.js} +1 -1
  307. package/dist/run-remote-BGKQDAOA.js +2 -0
  308. package/dist/{run-startup-gate-YO66G6LS.js → run-startup-gate-4XE73OON.js} +1 -1
  309. package/dist/run-test-md-G6U3RU2Q.js +19 -0
  310. package/dist/session-worker.js +2 -2
  311. package/dist/{sessions-CFV7FOIT.js → sessions-NH2EG7BP.js} +1 -1
  312. package/dist/{sessions-cmd-S7WZBUCN.js → sessions-cmd-CABAX7BO.js} +2 -2
  313. package/dist/{sessions-remote-IWHWIQ2T.js → sessions-remote-Y4FTZL7Y.js} +1 -1
  314. package/dist/{skill-installer-MAVQY6GW.js → skill-installer-FS2AV7GX.js} +1 -1
  315. package/dist/spawner-MQ4XEHIX.js +2 -0
  316. package/dist/{store-MSA7KASS.js → store-PLKJZTGC.js} +1 -1
  317. package/dist/store-choice-UAB6Z4AL.js +2 -0
  318. package/dist/store-guard-DUN2X3SR.js +2 -0
  319. package/dist/{store-site-KA2DNBGY.js → store-site-K5NHLI7D.js} +1 -1
  320. package/dist/stream-warnings-GM7YEOVG.js +2 -0
  321. package/dist/sync-cmd-AGTOGPYM.js +2 -0
  322. package/dist/{sync-setup-RBRDUV7Q.js → sync-setup-4KIY3PDO.js} +1 -1
  323. package/dist/tcg-generate-CUY4AZ2V.js +2 -0
  324. package/dist/{test-definition-VRI4YIYL.js → test-definition-53XNBEDE.js} +1 -1
  325. package/dist/testmd-actions-UD6PAWUX.js +2 -0
  326. package/dist/{testmd-sync-UPAA5UMD.js → testmd-sync-EEJ7GPLR.js} +1 -1
  327. package/dist/tms-client-XWCR7O7J.js +2 -0
  328. package/dist/token-refresh-K6PVBBFE.js +2 -0
  329. package/dist/{trust-gate-AT2XBWN4.js → trust-gate-674C2NZS.js} +1 -1
  330. package/dist/{turn-preflight-LHYLRL7G.js → turn-preflight-R4PU6NYY.js} +1 -1
  331. package/dist/{use-case-ref-NE4X4MZN.js → use-case-ref-44BPIP4N.js} +1 -1
  332. package/dist/{validate-basic-M5JHHNZA.js → validate-basic-3JZRZL45.js} +1 -1
  333. package/dist/{variable-receipt-BXSZO36E.js → variable-receipt-7PRKDTRJ.js} +1 -1
  334. package/dist/verdicts-PVB7TV5S.js +2 -0
  335. package/dist/{version-check-Q737BE65.js → version-check-IY3YSQIP.js} +1 -1
  336. package/dist/{view-cmd-XSNL5DGI.js → view-cmd-WUIGTRFX.js} +1 -1
  337. package/dist/{walk-session-SHGYLFRB.js → walk-session-EH7227WR.js} +1 -1
  338. package/dist/with-telemetry-7JMZUBUZ.js +2 -0
  339. package/package.json +17 -17
  340. package/dist/ChatSurface-6NZGMNHL.js +0 -2
  341. package/dist/EvidenceViewOffer-WIEWCZUP.js +0 -2
  342. package/dist/FolderPicker-AF7ZMV3M.js +0 -2
  343. package/dist/InfoBox-D7GGZJU4.js +0 -2
  344. package/dist/ProjectPicker-OBYHJJLU.js +0 -2
  345. package/dist/SaveSessionPrompt-7XSHS4NL.js +0 -2
  346. package/dist/SingleShotApp-XQUDR36R.js +0 -2
  347. package/dist/TestMdRunView-LS2QUFWR.js +0 -2
  348. package/dist/TestrunEvidenceTable-HNDVJDIF.js +0 -2
  349. package/dist/bind-4XWK3DG2.js +0 -2
  350. package/dist/bootstrap-6ACT4ALI.js +0 -2
  351. package/dist/bridge-T6QMYKED.js +0 -2
  352. package/dist/chat-committer-ZCSRJEUB.js +0 -2
  353. package/dist/chat-controller-XINCDH6Z.js +0 -2
  354. package/dist/child-G2GCW73X.js +0 -2
  355. package/dist/chunk-34R7BNZ2.js +0 -2
  356. package/dist/chunk-65VANXOF.js +0 -147
  357. package/dist/chunk-C6HI6Y3S.js +0 -2
  358. package/dist/chunk-D36V5OX6.js +0 -2
  359. package/dist/chunk-HCJ2N3XB.js +0 -12
  360. package/dist/chunk-IUQOG7Z5.js +0 -5
  361. package/dist/chunk-KF4DKXSS.js +0 -2
  362. package/dist/chunk-NC7D7GOM.js +0 -21
  363. package/dist/chunk-OGFU4YY4.js +0 -2
  364. package/dist/chunk-R4JUKTDO.js +0 -2
  365. package/dist/chunk-VZ4A6WMK.js +0 -97
  366. package/dist/chunk-W54OT2FU.js +0 -9
  367. package/dist/chunk-W72ACCFL.js +0 -27
  368. package/dist/chunk-WXJCJL5L.js +0 -7
  369. package/dist/cover-cmd-NBNZCR6C.js +0 -2
  370. package/dist/design-committer-TRYP3LOZ.js +0 -2
  371. package/dist/design-headless-OTHYOX3E.js +0 -2
  372. package/dist/device-env-CHFRRV6W.js +0 -2
  373. package/dist/dispatch-DVQ3H7EJ.js +0 -2
  374. package/dist/evidence-P6FFKC7B.js +0 -2
  375. package/dist/evidence-presentation-YYTIDCBS.js +0 -2
  376. package/dist/evolve-cmd-WWOB3QJR.js +0 -2
  377. package/dist/evolve-remote-WLVY3QID.js +0 -2
  378. package/dist/explore-K5YBGHK6.js +0 -2
  379. package/dist/extract-chat-M65NWGUK.js +0 -2
  380. package/dist/extract-headless-G6W6JQ27.js +0 -2
  381. package/dist/folder-flags-KKIH654K.js +0 -2
  382. package/dist/gaps-cmd-OIDDLRYL.js +0 -3
  383. package/dist/gate-7AKRPRMK.js +0 -2
  384. package/dist/gate-WISOUTHQ.js +0 -2
  385. package/dist/hold-passthrough-IOWPVB4W.js +0 -2
  386. package/dist/ingest-PDGS5ZTL.js +0 -2
  387. package/dist/ingest-remote-SSLUHQVG.js +0 -2
  388. package/dist/install-ZVBHPXGP.js +0 -2
  389. package/dist/lane-AQYRIW24.js +0 -2
  390. package/dist/lattice-auth-6FEVSR7E.js +0 -2
  391. package/dist/list-commands-5DCCKU3L.js +0 -2
  392. package/dist/login-flow-WEK3E476.js +0 -2
  393. package/dist/open-provider-OZAG6WZS.js +0 -2
  394. package/dist/pdf-convert-447ACUB3.js +0 -2
  395. package/dist/persist-recorded-session-A3ID7JFA.js +0 -3
  396. package/dist/phase-seed-LCJ4WSYV.js +0 -2
  397. package/dist/pipeline-GX3LKPI5.js +0 -2
  398. package/dist/prepare-target-FMT6QFHZ.js +0 -2
  399. package/dist/pull-route-FWBXJMR7.js +0 -2
  400. package/dist/readmodel-INMP6MNW.js +0 -2
  401. package/dist/real-device-run-X7JJWOIK.js +0 -2
  402. package/dist/reconcile-deps-TWJ3FTSU.js +0 -2
  403. package/dist/registry-VQC757MJ.js +0 -2
  404. package/dist/remote-entry-X6JMPC2K.js +0 -2
  405. package/dist/remote-mode-FDPA7EWG.js +0 -4
  406. package/dist/revert-FHOBLZWF.js +0 -2
  407. package/dist/run-5RQUCNYP.js +0 -2
  408. package/dist/run-PC5YO4AS.js +0 -2
  409. package/dist/run-remote-SJCRTL7O.js +0 -2
  410. package/dist/run-test-md-BLNBK4MH.js +0 -17
  411. package/dist/spawner-C7NLLM4F.js +0 -2
  412. package/dist/store-choice-3OJCV26J.js +0 -2
  413. package/dist/store-guard-OOSDLMEC.js +0 -2
  414. package/dist/stream-warnings-GEQKKJU7.js +0 -2
  415. package/dist/sync-cmd-RDFDMVKQ.js +0 -2
  416. package/dist/tcg-generate-KIECTZ2C.js +0 -2
  417. package/dist/testmd-actions-CMAG6HWI.js +0 -2
  418. package/dist/tms-client-NXAB6VJD.js +0 -2
  419. package/dist/token-refresh-KP3AYMYK.js +0 -2
  420. package/dist/verdicts-XK3GAUX3.js +0 -2
  421. package/dist/with-telemetry-PM2HVN2B.js +0 -2
@@ -1,17 +1,17 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as W,b as H}from"./chunk-PGESS7BW.js";import{a as G}from"./chunk-FWGUISUG.js";import{a as se,b as ae,c as ce,d as ue,e as le,q as U}from"./chunk-AZLNLHUA.js";import{a as xe}from"./chunk-DPGOAFKF.js";import{b as V}from"./chunk-ZFM77AQU.js";import{M as F,j as D,k as N}from"./chunk-UEE3RZN4.js";import{g as Ue,m as v}from"./chunk-4I7YN6YY.js";var A="https://integrations.lambdatest.com",y=class extends Error{constructor(t,r){super(r);this.code=t;this.name="LisError"}};function Nt(e){let n=e.TESTMUAI_ENV==="stage"?"stage":"prod";return`${Ue().authEnvironments[n].shareApiBaseUrl}/lis/api/v1`}function Pt(e){let n=e.env??process.env,t=e.auth?.TESTMUAI_BASIC_AUTH||n.TESTMUAI_BASIC_AUTH;if(t)return{authorization:`Basic ${t}`};let r=e.auth?.TESTMUAI_API_KEY||n.TESTMUAI_API_KEY;return r?{authorization:`Bearer ${r}`}:{}}function C(e){let n=e.split(`
2
+ import{a as xe}from"./chunk-GBQ4K25P.js";import{a as W,b as H}from"./chunk-PGESS7BW.js";import{a as G}from"./chunk-FWGUISUG.js";import{a as se,b as ae,c as ce,d as ue,e as le,q as U}from"./chunk-Z24SD2EJ.js";import{b as V}from"./chunk-CQDCNP7V.js";import{M as F,j as D,k as N}from"./chunk-PI7OXS62.js";import{g as Ue,o as v}from"./chunk-HYJVYYAZ.js";var A="https://integrations.lambdatest.com",y=class extends Error{constructor(t,r){super(r);this.code=t;this.name="LisError"}};function Nt(e){let n=e.TESTMUAI_ENV==="stage"?"stage":"prod";return`${Ue().authEnvironments[n].shareApiBaseUrl}/lis/api/v1`}function Pt(e){let n=e.env??process.env,t=e.auth?.TESTMUAI_BASIC_AUTH||n.TESTMUAI_BASIC_AUTH;if(t)return{authorization:`Basic ${t}`};let r=e.auth?.TESTMUAI_API_KEY||n.TESTMUAI_API_KEY;return r?{authorization:`Bearer ${r}`}:{}}function C(e){let n=e.split(`
3
3
  `,1)[0].replace(/[\u0000-\u001f\u007f-\u009f]/g,"");return n.length>200?`${n.slice(0,200)}\u2026`:n}function Tt(e,n,t="the issue"){return e===401||e===403?new y("LIS_AUTH",v().text("LIS_AUTH",{})):e>=500?new y("LIS_UNAVAILABLE",`the integrations service returned an error (HTTP ${e}) \u2014 retry later`):new y("JIRA_ISSUE_UNAVAILABLE",`could not fetch ${t}: ${C(n)||`HTTP ${e}`}`)}function P(e){try{return JSON.parse(e.bytes.toString("utf8"))}catch{throw new y("LIS_UNAVAILABLE","the integrations service returned a malformed response \u2014 retry later")}}function be(e){try{return JSON.parse(e.bytes.toString("utf8"))}catch{return{}}}function Be(e){return be(e).code}function R(e,n="the issue",t="Atlassian"){let r=be(e),i=t==="Atlassian"?"Confluence":t;switch(r.code){case"TOKEN_EXPIRED":return new y("LIS_SETUP",`your ${t} connection needs a resync \u2014 reconnect at ${A} and retry`);case"NOT_INSTALLED":return new y("LIS_SETUP",`no ${t} connection for this account \u2014 create one at ${A} and retry`);case"SCOPE_MISSING":return new y("LIS_SETUP",`the connection has no ${i} access \u2014 reconnect with ${i} at ${A} and retry`);case"FORBIDDEN":return new y("LIS_FORBIDDEN",`you don't have access to ${n}`);case"NOT_FOUND":return new y("JIRA_ISSUE_UNAVAILABLE",`could not fetch ${n}: ${C(r.message??"")||"not found"}`);case"PAYLOAD_TOO_LARGE":return new y("ATTACHMENT_TOO_LARGE","the attachment exceeds the integrations service's size cap");case"INVALID_PAYLOAD":return new y("LIS_UNAVAILABLE",`the integrations service rejected the request (${C(r.message??"")||"invalid payload"}) \u2014 retry later`);case"NOT_SUPPORTED":return new y("LIS_UNAVAILABLE","the integrations service does not support this operation yet");case"UPSTREAM_ERROR":case"UPSTREAM_TIMEOUT":return new y("LIS_UNAVAILABLE",`${t} is not responding through the integrations service \u2014 retry later`);default:return Tt(e.status,r.message??"",n)}}var Dt=3e4,Ut=5;async function k(e,n,t){let r=t.env??process.env,i=t.fetchImpl??fetch;for(let o=0;;o++){let u=new AbortController,l=setTimeout(()=>u.abort(),Dt);try{let s=await i(`${Nt(r)}${e}`,{...n,headers:{"content-type":"application/json",...Pt(t),...n.headers??{}},signal:u.signal}),c=await Promise.race([s.arrayBuffer(),new Promise((f,p)=>{u.signal.addEventListener("abort",()=>p(new DOMException("aborted","AbortError")),{once:!0})})]),a={status:s.status,ok:s.ok,headers:s.headers,bytes:Buffer.from(c)};if(a.status===429){if(o>0)throw new y("LIS_RATE_LIMITED","the integrations service is busy \u2014 try again in a moment");let f=be(a).data?.retry_after_sec,p=Math.min(Math.max(typeof f=="number"&&Number.isFinite(f)?f:1,0),Ut);clearTimeout(l),await new Promise(h=>setTimeout(h,p*1e3));continue}return a}catch(s){throw s instanceof y?s:u.signal.aborted?new y("LIS_UNAVAILABLE","the integrations service did not respond within 30 seconds \u2014 retry later"):new y("LIS_UNAVAILABLE",`could not reach the integrations service (${C(s instanceof Error?s.message:String(s))}) \u2014 check your connection and retry`)}finally{clearTimeout(l)}}}function Y(e){let n=e.headers.get("content-type")??"application/octet-stream";if(n.includes("json"))try{let t=JSON.parse(e.bytes.toString("utf8")),r=t.content??t.data?.content;if(typeof r=="string")return{bytes:Buffer.from(r,"base64"),mediaType:t.mime_type??t.data?.mime_type??"application/octet-stream"}}catch{}return{bytes:e.bytes,mediaType:n}}async function q(e={}){let n=await k("/jira/info",{method:"GET"},e);if(!n.ok)throw R(n);let t=P(n),r=(t.data?.SELECTED_PROJECTS??[]).map(i=>i?.key).filter(i=>typeof i=="string"&&i.length>0);return{installed:t.data?.INSTALLED==="YES",selectAll:t.data?.SELECT_ALL===!0,selectedProjects:r,capabilities:{document:t.data?.capabilities?.document===!0,comments:t.data?.capabilities?.comments===!0}}}async function Q(e,n={}){let t=await k("/jira/issue?details=true",{method:"POST",body:JSON.stringify({plugin_code:"jira",issueKey:e})},n);if(!t.ok)throw R(t);let r=P(t);if(r.type==="error"||!r.data)throw new y("JIRA_ISSUE_UNAVAILABLE",`could not fetch the issue: ${C(r.message??"")||"issue not found or not accessible"}`);return r.data}var je=100,xt=5e3,Bt=60;async function ee(e,n={}){let t=[],r=new Set,i=null,o=0;for(let u=0;;u++){if(u>=Bt)throw new y("LIS_UNAVAILABLE","the integrations service kept returning comment pages without finishing \u2014 retry later");let l=await k("/jira/issue/comments",{method:"POST",body:JSON.stringify({resource_id:e,max_results:je,cursor:i,start_at:o,order_by:"created",fetch_all:!1})},n);if(!l.ok)throw R(l,"the issue's comments");let s=P(l);if(s.type==="error"||!s.data)throw new y("JIRA_ISSUE_UNAVAILABLE",`could not fetch the issue's comments: ${C(s.message??"")||"unavailable"}`);for(let g of s.data.comments??[]){let d=String(g.id);r.has(d)||(r.add(d),t.push(g))}let c=s.data.pagination;if(!c?.has_more)return t;if(t.length>=xt)throw new y("JIRA_ISSUE_UNAVAILABLE","the issue has more comments than can be ingested \u2014 cannot build a complete identity");let a=c.next_cursor??null,f=c.next_start_at!=null,p=f?c.next_start_at:o+je;if(!(a!=null&&a!==i||a==null&&f&&p!==o))throw new y("LIS_UNAVAILABLE","the integrations service returned a non-advancing comments page \u2014 retry later");i=a,o=p}}async function te(e,n={}){let t=await k("/jira/attachment",{method:"POST",body:JSON.stringify({attachment_id:e})},n);if(!t.ok){if(Be(t)===void 0){if(t.status===413)throw new y("ATTACHMENT_TOO_LARGE","the attachment exceeds the integrations service's size cap");if(t.status===404)throw new y("JIRA_NOT_CONNECTED",`Jira is not connected for this account \u2014 connect it at ${A} and retry`)}throw R(t,`attachment ${e}`)}return Y(t)}var de="kane.source.jira/2";function Me(e){if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e)){let n=e.map(Me).filter(t=>t!==null);return n.length===0?null:n.join(", ")}if(e!==null&&typeof e=="object"){let n=e;for(let t of["name","value","displayName"])if(typeof n[t]=="string")return n[t];return null}return null}function Fe(e,n,t){let r=[],i={},o=e.additional_fields??{};for(let a of Object.keys(o).sort()){let f=Me(o[a]);if(f===null){r.push(`field "${a}" has no stable text form \u2014 dropped from the envelope`);continue}i[a]=f}let u=[...e.attachments??[]].map(a=>({id:String(a.id),filename:a.filename??"",media_type:a.mime_type??"application/octet-stream",size:a.size??0})).sort((a,f)=>{let p=Number(a.id),h=Number(f.id);return Number.isFinite(p)&&Number.isFinite(h)?p-h:a.id<f.id?-1:a.id>f.id?1:0}),l=t.map(a=>({id:String(a.id),author:a.author?.display_name??"",body:a.body??"",created:a.created??""})).sort((a,f)=>{if(a.created!==f.created)return a.created<f.created?-1:1;let p=Number(a.id),h=Number(f.id);return Number.isFinite(p)&&Number.isFinite(h)&&p!==h?p-h:a.id<f.id?-1:a.id>f.id?1:0}),s=e.key;if(!/^[A-Za-z][A-Za-z0-9_]*-\d+$/.test(s))throw new Error(`cannot build a stable identity for issue key "${s}" \u2014 expected a PROJECT-NUMBER key`);let c={schema:de,site:n,project:s.slice(0,s.lastIndexOf("-")),issue:{id:e.id,key:s},content:{summary:e.summary??"",description:e.description??"",fields:i},attachments:u,comments:l};return{bytes:Buffer.from(JSON.stringify(c),"utf8"),envelope:c,warnings:r}}var Je=64,jt=16,Mt=6e6,Ft=5e7,Jt=12e6,Kt={png:"image/png",jpeg:"image/jpeg",webp:"image/webp",gif:"image/gif",bmp:"image/bmp",tiff:"image/tiff",emf:"image/emf",wmf:"image/wmf",unknown:"application/octet-stream"},Vt=new Set(["png","jpeg","webp"]);function _e(e){return async n=>{let t;try{t=JSON.parse(n.toString("utf8"))}catch{throw new Error("JIRA_ENVELOPE_SCHEMA: source bytes are not a kane jira envelope")}if(t.schema!==de)throw new Error(`JIRA_ENVELOPE_SCHEMA: unknown envelope schema "${t.schema}" \u2014 this CLI understands ${de}`);let r=[],i=new Map,o=[],u=0,l=new Map,s=[];for(let f=0;f<t.attachments.length;f++){let p=t.attachments[f],h=`i${f+1}`,g=`attachment:${p.filename}`,d=S=>`[img#${h}] ${p.filename} (${p.media_type}, ${p.size} bytes${S?"":" \u2014 not delivered"})`,m=(S,O,M)=>{r.push({ref:h,loc:g,media_type:S,...M?.blob?{blob:M.blob}:{},...M?.appearance?{appearance:M.appearance}:{},delivery:O,...M?.duplicate_of?{duplicate_of:M.duplicate_of}:{}})};if(!p.media_type.startsWith("image/")){m(p.media_type,"unsupported-vision-media-type"),s.push(d(!1));continue}let E;try{E=await e.fetchAttachment(p.id)}catch{m(p.media_type,"external-image-not-fetched"),s.push(d(!1));continue}let I=E.bytes,w=W(I),b=Kt[w.format],L=V(I);if(i.set(L,I),!Vt.has(w.format)){let S=w.format==="gif"||w.format==="bmp"||w.format==="tiff"?"unsupported-vision-media-type":"unsupported-image-kind";m(b,S,{blob:L}),s.push(d(!1));continue}if(w.width===void 0||w.height===void 0||w.width*w.height>Ft){m(b,"undecodable",{blob:L}),s.push(d(!1));continue}let _;if(w.format==="png"||w.format==="jpeg"){let S=H(I,w.format);if(S===null){m(b,"undecodable",{blob:L}),s.push(d(!1));continue}_=G(S.data,{width:S.width,height:S.height,channels:S.channels})}if(w.width<Je||w.height<Je){m(b,"below-dimension-floor",{blob:L,appearance:_}),s.push(d(!1));continue}let T=l.get(L);if(T!==void 0){m(b,"duplicate",{blob:L,appearance:_,duplicate_of:T}),s.push(d(!1));continue}if(I.byteLength>Mt){m(b,"image-too-large",{blob:L,appearance:_}),s.push(d(!1));continue}if(u+I.byteLength>Jt){m(b,"vision-byte-budget-reached",{blob:L,appearance:_}),s.push(d(!1));continue}if(o.length>=jt){m(b,"image-cap-reached",{blob:L,appearance:_}),s.push(d(!1));continue}l.set(L,h),u+=I.byteLength,o.push(h),m(b,"selected",{blob:L,appearance:_}),s.push(d(!0))}let c=[];c.push(`${t.issue.key} \xB7 ${t.site}/${t.project}`,`Summary: ${t.content.summary}`),t.content.description!==""&&c.push("",...t.content.description.split(`
4
4
  `));let a=Object.keys(t.content.fields);return a.length>0&&c.push("","--- fields ---",...a.map(f=>`${f}: ${t.content.fields[f]}`)),s.length>0&&c.push("","--- attachments ---",...s),t.comments.length>0&&(c.push("","--- comments ---"),t.comments.forEach((f,p)=>{p>0&&c.push(""),c.push(`[${p+1}] ${f.author} \xB7 ${f.created}`,...f.body.split(`
5
5
  `))})),{projection:c.join(`
6
6
  `)+`
7
- `,inventory:r,blobs:i,delivered:o,converter:{name:"jira-convert",version:"2",policy:"v1"}}}}var Gt=/^[A-Za-z][A-Za-z0-9_]*-\d+$/;function ne(e){if(!/^https?:\/\/.+/i.test(e))return null;let n;try{n=new URL(e)}catch{return null}let t=n.pathname.split("/").filter(Boolean),r=t.lastIndexOf("browse");if(r===-1||r+1>=t.length)return null;let i=t[r+1];return Gt.test(i)?{site:n.hostname,issueKey:i.toUpperCase()}:null}function pe(e,n){let t=F(e),r=t.heads.get(n);return r==null?null:Ve(e,t,r)}function fe(e,n){let r=pe(e,n)?.site;return typeof r=="string"&&r.length>0?r:null}function we(e,n,t,r){let i=F(e);for(let[o,u]of i.heads){if(u==null||i.mediaOf(u).format!==n)continue;let l=Ve(e,i,u);if(l===null)continue;let s=l;for(let c of t){if(s===null||typeof s!="object"){s=void 0;break}s=s[c]}if(s===r)return o}return null}function Ve(e,n,t){let r=n.getNode(t)?.content?.blob;if(typeof r!="string")return null;let i=e.getBlob(r);if(i===null)return null;try{let o=JSON.parse(i.toString("utf8"));return o!==null&&typeof o=="object"?o:null}catch{return null}}var Ke={jira:"a jira issue source",confluence:"a confluence page source",linear:"a linear issue source","linear-doc":"a linear document source",web:"a web page source"};function x(e,n,t){let r=F(e),i=r.heads.get(n);if(i==null)return null;let o=r.mediaOf(i).format;if(o===t)return null;let u=Ke[o]??`${o} content`;return v().text("note.kind_taken",{source_id:n,backing:u,kind:Ke[t]??t})}function $(e,n){let t=F(e);for(let r=2;;r++)if(!t.heads.has(`${n}-${r}`))return`${n}-${r}`}function J(e,n){let t=F(e),r=t.heads.get(n);return r==null?null:t.mediaOf(r).format}async function Ge(e,n,t){let r=t.lis??{jiraInfo:q,jiraIssue:Q,jiraAttachment:te,jiraComments:ee};try{let o={auth:await(t.authEnv??(async()=>(await import("./auth-7Z54TMQQ.js")).resolveLisAuthEnv({credentials:t.credentials})))(),env:process.env},u=await r.jiraInfo(o);if(!u.installed)return{ok:!1,failure:{code:"NO_CONNECTION",message:`no Atlassian connection for this account \u2014 create one at ${A} and retry`}};if(u.capabilities.comments===!1)return{ok:!1,failure:{code:"NO_COMMENTS_ACCESS",message:`the connection cannot read issue comments yet \u2014 resync it at ${A} and retry`}};let l=e.issueKey.slice(0,e.issueKey.lastIndexOf("-"));if(!u.selectAll&&u.selectedProjects.length>0&&!u.selectedProjects.includes(l))return{ok:!1,failure:{code:"PROJECT_NOT_SELECTED",message:`project ${l} is not in the integration's selected projects (${u.selectedProjects.join(", ")}) \u2014 add it at ${A}`,facts:{project:l}}};let s=await r.jiraIssue(e.issueKey,o),c=await r.jiraComments(e.issueKey,o),a=e.site;if(s.host)try{a=new URL(s.host).hostname}catch{a=s.host.replace(/^https?:\/\//,"").replace(/[/:].*$/,"")}let{bytes:f,warnings:p}=Fe(s,a,c),h=n??e.issueKey.toLowerCase();try{N(h)}catch(g){return{ok:!1,failure:{code:"BAD_SOURCE_ID",message:g instanceof Error?g.message:String(g)}}}return{ok:!0,bytes:f,site:a,sourceId:h,warnings:p,lis:r,lisDeps:o}}catch(i){return i instanceof y?{ok:!1,failure:{code:i.code,message:i.message}}:{ok:!1,failure:{code:"FETCH_FAILED",message:He(i instanceof Error?i.message:String(i))}}}}function We(e,n,t){let r=x(e,n,"jira");if(r!==null)return{code:"KIND_MISMATCH",message:r,facts:{id:n,heldKind:J(e,n)??"",freeId:$(e,n)}};let i=fe(e,n);return i!==null&&i!==t?{code:"SITE_MOVED",message:v().text("note.site_moved",{source_id:n,previous:i,site:t}),facts:{id:n,freeId:$(e,n)}}:null}async function Wt(e,n,t,r,i){let o=ne(e);if(o===null)return(t.err??t.out)(`error: ${e}: unsupported remote URL \u2014 expected a Jira issue URL (https://<site>/browse/KEY-123)`),{code:1};let u=await Ge(o,n,i);if(!u.ok)return(t.err??t.out)(`error: ${e}: ${u.failure.message}`),{code:1};let{bytes:l,site:s,sourceId:c,warnings:a,lis:f,lisDeps:p}=u;try{let h=We(r,c,s);if(h!==null)return(t.err??t.out)(`error: ${e}: ${h.message}`),{code:1};let g=await U({store:r,bytes:l,media:se,sourceId:c,label:e,confirmSameSource:t.isTTY?d=>t.confirm(`identical content already ingested as ${d} \u2014 treat as the same source?`):void 0,converters:{jira:_e({fetchAttachment:d=>f.jiraAttachment(d,p)})}});t.out(B(t.isTTY,g,o.issueKey));for(let d of a)t.out(`warning: ${d}`);for(let d of g.warnings??[])t.out(`warning: ${d}`);if(g.composite){let d=g.composite.delivered+g.composite.omitted;t.out(`${g.source_id}: jira, ${d} attachments, ${g.composite.delivered} images delivered (${g.composite.omitted} omitted)`)}return{code:0,result:{status:g.status,source_id:g.source_id,source_cid:g.cid,...g.gitignore?{gitignore:g.gitignore}:{}}}}catch(h){return h instanceof y?((t.err??t.out)(`error: ${e}: ${h.message}`),{code:1}):((t.err??t.out)(`error: ${e}: ${He(h instanceof Error?h.message:String(h))}`),{code:1})}}async function Ht(e,n,t){let r=ne(e);if(r===null)return{ok:!1,failure:{code:"UNSUPPORTED_URL",message:"unsupported remote URL \u2014 expected a Jira issue URL (https://<site>/browse/KEY-123)"}};if(n!==void 0&&!D(n))return{ok:!1,failure:{code:"BAD_SOURCE_ID",message:j(n)}};let i=await Ge(r,n,t);return i.ok?{ok:!0,fetched:{provider:"jira",sourceId:i.sourceId,bytes:i.bytes,media:se,label:e,display:r.issueKey,origin:{kind:"jira",url:e},identity:{site:i.site},warnings:i.warnings}}:i}async function Yt(e,n,t){let r=We(n,e.sourceId,e.identity.site??"");if(r!==null)return{ok:!1,failure:r};let i=t.lis??{jiraInfo:q,jiraIssue:Q,jiraAttachment:te,jiraComments:ee},u={auth:await(t.authEnv??(async()=>(await import("./auth-7Z54TMQQ.js")).resolveLisAuthEnv({credentials:t.credentials})))(),env:process.env};return{ok:!0,media:se,label:e.label,converters:{jira:_e({fetchAttachment:l=>i.jiraAttachment(l,u)})}}}function He(e){let n=e.match(/too large — ([\d.]+ [KM]B), the limit for .+ is ([\d.]+ [KM]B) \[FILE_TOO_LARGE\]/);return n?`the issue's content is too large to ingest (${n[1]}; the limit is ${n[2]}) \u2014 trim the description or attachments in Jira and retry`:e.startsWith("PROJECTION_TOO_LARGE:")?"the issue's text is too large to ingest \u2014 trim the description in Jira and retry":e}var Ye={name:"jira",hint:"Jira issue URLs (https://<site>/browse/KEY-123)",match:e=>ne(e)!==null,ingest:Wt,sourceIdFor:e=>{let n=ne(e);return n?n.issueKey.toLowerCase():null},fetch:Ht,prepare:Yt};async function Le(e,n={}){let t=await k("/jira/document",{method:"POST",body:JSON.stringify({resource_id:e,format:"markdown"})},n);if(!t.ok)throw R(t,"the page");let r=P(t);if(r.type==="error"||!r.data)throw new y("JIRA_ISSUE_UNAVAILABLE",`could not fetch the page: ${C(r.message??"")||"page not found or not accessible"}`);return r.data}async function Ie(e,n={}){let t=await k("/jira/attachment",{method:"POST",body:JSON.stringify({source:"confluence",download:e})},n);if(!t.ok)throw R(t,"the page's attachment");return{bytes:Y(t).bytes}}var me="kane.source.confluence/1";function ze(e,n){if(typeof e.id!="string"||e.id==="")throw new Error("cannot build a stable identity for this page \u2014 the integrations service returned no page id");let t=[...e.labels??[]].filter(o=>typeof o=="string").sort(),r=[...e.attachments??[]].map(o=>({id:String(o.id),filename:o.filename??"",media_type:o.mime_type??"application/octet-stream",size:o.size??0})).sort((o,u)=>o.id<u.id?-1:o.id>u.id?1:0),i={schema:me,site:n,page:{id:e.id},space:{key:e.space?.key??""},title:e.title??"",labels:t,content:{body:e.body??""},attachments:r};return{bytes:Buffer.from(JSON.stringify(i),"utf8"),envelope:i,warnings:[]}}var Xe=64,zt=16,Xt=6e6,Zt=5e7,qt=12e6,Qt={png:"image/png",jpeg:"image/jpeg",webp:"image/webp",gif:"image/gif",bmp:"image/bmp",tiff:"image/tiff",emf:"image/emf",wmf:"image/wmf",unknown:"application/octet-stream"},en=new Set(["png","jpeg","webp"]);function Ze(e){let n=new Map(Object.entries(e.downloads));return async t=>{let r;try{r=JSON.parse(t.toString("utf8"))}catch{throw new Error("CONFLUENCE_ENVELOPE_SCHEMA: source bytes are not a kane confluence envelope")}if(r.schema!==me)throw new Error(`CONFLUENCE_ENVELOPE_SCHEMA: unknown envelope schema "${r.schema}" \u2014 this CLI understands ${me}`);let i=[],o=new Map,u=[],l=0,s=new Map,c=[];for(let f=0;f<r.attachments.length;f++){let p=r.attachments[f],h=`i${f+1}`,g=`attachment:${p.filename}`,d=O=>`[img#${h}] ${p.filename} (${p.media_type}, ${p.size} bytes${O?"":" \u2014 not delivered"})`,m=(O,M,K)=>{i.push({ref:h,loc:g,media_type:O,...K?.blob?{blob:K.blob}:{},...K?.appearance?{appearance:K.appearance}:{},delivery:M,...K?.duplicate_of?{duplicate_of:K.duplicate_of}:{}})};if(!p.media_type.startsWith("image/")){m(p.media_type,"unsupported-vision-media-type"),c.push(d(!1));continue}let E=n.get(p.id);if(!E){m(p.media_type,"external-image-not-fetched"),c.push(d(!1));continue}let I;try{I=await e.fetchAttachment({id:p.id,download:E})}catch{m(p.media_type,"external-image-not-fetched"),c.push(d(!1));continue}let w=I.bytes,b=W(w),L=Qt[b.format],_=V(w);if(o.set(_,w),!en.has(b.format)){let O=b.format==="gif"||b.format==="bmp"||b.format==="tiff"?"unsupported-vision-media-type":"unsupported-image-kind";m(L,O,{blob:_}),c.push(d(!1));continue}if(b.width===void 0||b.height===void 0||b.width*b.height>Zt){m(L,"undecodable",{blob:_}),c.push(d(!1));continue}let T;if(b.format==="png"||b.format==="jpeg"){let O=H(w,b.format);if(O===null){m(L,"undecodable",{blob:_}),c.push(d(!1));continue}T=G(O.data,{width:O.width,height:O.height,channels:O.channels})}if(b.width<Xe||b.height<Xe){m(L,"below-dimension-floor",{blob:_,appearance:T}),c.push(d(!1));continue}let S=s.get(_);if(S!==void 0){m(L,"duplicate",{blob:_,appearance:T,duplicate_of:S}),c.push(d(!1));continue}if(w.byteLength>Xt){m(L,"image-too-large",{blob:_,appearance:T}),c.push(d(!1));continue}if(l+w.byteLength>qt){m(L,"vision-byte-budget-reached",{blob:_,appearance:T}),c.push(d(!1));continue}if(u.length>=zt){m(L,"image-cap-reached",{blob:_,appearance:T}),c.push(d(!1));continue}s.set(_,h),l+=w.byteLength,u.push(h),m(L,"selected",{blob:_,appearance:T}),c.push(d(!0))}let a=[];return a.push(`${r.title} \xB7 ${r.site} \xB7 ${r.space.key}`),r.labels.length>0&&a.push(`labels: ${r.labels.join(", ")}`),r.content.body!==""&&a.push("",...r.content.body.split(`
7
+ `,inventory:r,blobs:i,delivered:o,converter:{name:"jira-convert",version:"2",policy:"v1"}}}}var Gt=/^[A-Za-z][A-Za-z0-9_]*-\d+$/;function ne(e){if(!/^https?:\/\/.+/i.test(e))return null;let n;try{n=new URL(e)}catch{return null}let t=n.pathname.split("/").filter(Boolean),r=t.lastIndexOf("browse");if(r===-1||r+1>=t.length)return null;let i=t[r+1];return Gt.test(i)?{site:n.hostname,issueKey:i.toUpperCase()}:null}function pe(e,n){let t=F(e),r=t.heads.get(n);return r==null?null:Ve(e,t,r)}function fe(e,n){let r=pe(e,n)?.site;return typeof r=="string"&&r.length>0?r:null}function we(e,n,t,r){let i=F(e);for(let[o,u]of i.heads){if(u==null||i.mediaOf(u).format!==n)continue;let l=Ve(e,i,u);if(l===null)continue;let s=l;for(let c of t){if(s===null||typeof s!="object"){s=void 0;break}s=s[c]}if(s===r)return o}return null}function Ve(e,n,t){let r=n.getNode(t)?.content?.blob;if(typeof r!="string")return null;let i=e.getBlob(r);if(i===null)return null;try{let o=JSON.parse(i.toString("utf8"));return o!==null&&typeof o=="object"?o:null}catch{return null}}var Ke={jira:"a jira issue source",confluence:"a confluence page source",linear:"a linear issue source","linear-doc":"a linear document source",web:"a web page source"};function x(e,n,t){let r=F(e),i=r.heads.get(n);if(i==null)return null;let o=r.mediaOf(i).format;if(o===t)return null;let u=Ke[o]??`${o} content`;return v().text("note.kind_taken",{source_id:n,backing:u,kind:Ke[t]??t})}function $(e,n){let t=F(e);for(let r=2;;r++)if(!t.heads.has(`${n}-${r}`))return`${n}-${r}`}function J(e,n){let t=F(e),r=t.heads.get(n);return r==null?null:t.mediaOf(r).format}async function Ge(e,n,t){let r=t.lis??{jiraInfo:q,jiraIssue:Q,jiraAttachment:te,jiraComments:ee};try{let o={auth:await(t.authEnv??(async()=>(await import("./auth-WBIEHHDS.js")).resolveLisAuthEnv({credentials:t.credentials})))(),env:process.env},u=await r.jiraInfo(o);if(!u.installed)return{ok:!1,failure:{code:"NO_CONNECTION",message:`no Atlassian connection for this account \u2014 create one at ${A} and retry`}};if(u.capabilities.comments===!1)return{ok:!1,failure:{code:"NO_COMMENTS_ACCESS",message:`the connection cannot read issue comments yet \u2014 resync it at ${A} and retry`}};let l=e.issueKey.slice(0,e.issueKey.lastIndexOf("-"));if(!u.selectAll&&u.selectedProjects.length>0&&!u.selectedProjects.includes(l))return{ok:!1,failure:{code:"PROJECT_NOT_SELECTED",message:`project ${l} is not in the integration's selected projects (${u.selectedProjects.join(", ")}) \u2014 add it at ${A}`,facts:{project:l}}};let s=await r.jiraIssue(e.issueKey,o),c=await r.jiraComments(e.issueKey,o),a=e.site;if(s.host)try{a=new URL(s.host).hostname}catch{a=s.host.replace(/^https?:\/\//,"").replace(/[/:].*$/,"")}let{bytes:f,warnings:p}=Fe(s,a,c),h=n??e.issueKey.toLowerCase();try{N(h)}catch(g){return{ok:!1,failure:{code:"BAD_SOURCE_ID",message:g instanceof Error?g.message:String(g)}}}return{ok:!0,bytes:f,site:a,sourceId:h,warnings:p,lis:r,lisDeps:o}}catch(i){return i instanceof y?{ok:!1,failure:{code:i.code,message:i.message}}:{ok:!1,failure:{code:"FETCH_FAILED",message:He(i instanceof Error?i.message:String(i))}}}}function We(e,n,t){let r=x(e,n,"jira");if(r!==null)return{code:"KIND_MISMATCH",message:r,facts:{id:n,heldKind:J(e,n)??"",freeId:$(e,n)}};let i=fe(e,n);return i!==null&&i!==t?{code:"SITE_MOVED",message:v().text("note.site_moved",{source_id:n,previous:i,site:t}),facts:{id:n,freeId:$(e,n)}}:null}async function Wt(e,n,t,r,i){let o=ne(e);if(o===null)return(t.err??t.out)(`error: ${e}: unsupported remote URL \u2014 expected a Jira issue URL (https://<site>/browse/KEY-123)`),{code:1};let u=await Ge(o,n,i);if(!u.ok)return(t.err??t.out)(`error: ${e}: ${u.failure.message}`),{code:1};let{bytes:l,site:s,sourceId:c,warnings:a,lis:f,lisDeps:p}=u;try{let h=We(r,c,s);if(h!==null)return(t.err??t.out)(`error: ${e}: ${h.message}`),{code:1};let g=await U({store:r,bytes:l,media:se,sourceId:c,label:e,confirmSameSource:t.isTTY?d=>t.confirm(`identical content already ingested as ${d} \u2014 treat as the same source?`):void 0,converters:{jira:_e({fetchAttachment:d=>f.jiraAttachment(d,p)})}});t.out(B(t.isTTY,g,o.issueKey));for(let d of a)t.out(`warning: ${d}`);for(let d of g.warnings??[])t.out(`warning: ${d}`);if(g.composite){let d=g.composite.delivered+g.composite.omitted;t.out(`${g.source_id}: jira, ${d} attachments, ${g.composite.delivered} images delivered (${g.composite.omitted} omitted)`)}return{code:0,result:{status:g.status,source_id:g.source_id,source_cid:g.cid,...g.gitignore?{gitignore:g.gitignore}:{}}}}catch(h){return h instanceof y?((t.err??t.out)(`error: ${e}: ${h.message}`),{code:1}):((t.err??t.out)(`error: ${e}: ${He(h instanceof Error?h.message:String(h))}`),{code:1})}}async function Ht(e,n,t){let r=ne(e);if(r===null)return{ok:!1,failure:{code:"UNSUPPORTED_URL",message:"unsupported remote URL \u2014 expected a Jira issue URL (https://<site>/browse/KEY-123)"}};if(n!==void 0&&!D(n))return{ok:!1,failure:{code:"BAD_SOURCE_ID",message:j(n)}};let i=await Ge(r,n,t);return i.ok?{ok:!0,fetched:{provider:"jira",sourceId:i.sourceId,bytes:i.bytes,media:se,label:e,display:r.issueKey,origin:{kind:"jira",url:e},identity:{site:i.site},warnings:i.warnings}}:i}async function Yt(e,n,t){let r=We(n,e.sourceId,e.identity.site??"");if(r!==null)return{ok:!1,failure:r};let i=t.lis??{jiraInfo:q,jiraIssue:Q,jiraAttachment:te,jiraComments:ee},u={auth:await(t.authEnv??(async()=>(await import("./auth-WBIEHHDS.js")).resolveLisAuthEnv({credentials:t.credentials})))(),env:process.env};return{ok:!0,media:se,label:e.label,converters:{jira:_e({fetchAttachment:l=>i.jiraAttachment(l,u)})}}}function He(e){let n=e.match(/too large — ([\d.]+ [KM]B), the limit for .+ is ([\d.]+ [KM]B) \[FILE_TOO_LARGE\]/);return n?`the issue's content is too large to ingest (${n[1]}; the limit is ${n[2]}) \u2014 trim the description or attachments in Jira and retry`:e.startsWith("PROJECTION_TOO_LARGE:")?"the issue's text is too large to ingest \u2014 trim the description in Jira and retry":e}var Ye={name:"jira",hint:"Jira issue URLs (https://<site>/browse/KEY-123)",match:e=>ne(e)!==null,ingest:Wt,sourceIdFor:e=>{let n=ne(e);return n?n.issueKey.toLowerCase():null},fetch:Ht,prepare:Yt};async function Le(e,n={}){let t=await k("/jira/document",{method:"POST",body:JSON.stringify({resource_id:e,format:"markdown"})},n);if(!t.ok)throw R(t,"the page");let r=P(t);if(r.type==="error"||!r.data)throw new y("JIRA_ISSUE_UNAVAILABLE",`could not fetch the page: ${C(r.message??"")||"page not found or not accessible"}`);return r.data}async function Ie(e,n={}){let t=await k("/jira/attachment",{method:"POST",body:JSON.stringify({source:"confluence",download:e})},n);if(!t.ok)throw R(t,"the page's attachment");return{bytes:Y(t).bytes}}var me="kane.source.confluence/1";function ze(e,n){if(typeof e.id!="string"||e.id==="")throw new Error("cannot build a stable identity for this page \u2014 the integrations service returned no page id");let t=[...e.labels??[]].filter(o=>typeof o=="string").sort(),r=[...e.attachments??[]].map(o=>({id:String(o.id),filename:o.filename??"",media_type:o.mime_type??"application/octet-stream",size:o.size??0})).sort((o,u)=>o.id<u.id?-1:o.id>u.id?1:0),i={schema:me,site:n,page:{id:e.id},space:{key:e.space?.key??""},title:e.title??"",labels:t,content:{body:e.body??""},attachments:r};return{bytes:Buffer.from(JSON.stringify(i),"utf8"),envelope:i,warnings:[]}}var Xe=64,zt=16,Xt=6e6,Zt=5e7,qt=12e6,Qt={png:"image/png",jpeg:"image/jpeg",webp:"image/webp",gif:"image/gif",bmp:"image/bmp",tiff:"image/tiff",emf:"image/emf",wmf:"image/wmf",unknown:"application/octet-stream"},en=new Set(["png","jpeg","webp"]);function Ze(e){let n=new Map(Object.entries(e.downloads));return async t=>{let r;try{r=JSON.parse(t.toString("utf8"))}catch{throw new Error("CONFLUENCE_ENVELOPE_SCHEMA: source bytes are not a kane confluence envelope")}if(r.schema!==me)throw new Error(`CONFLUENCE_ENVELOPE_SCHEMA: unknown envelope schema "${r.schema}" \u2014 this CLI understands ${me}`);let i=[],o=new Map,u=[],l=0,s=new Map,c=[];for(let f=0;f<r.attachments.length;f++){let p=r.attachments[f],h=`i${f+1}`,g=`attachment:${p.filename}`,d=O=>`[img#${h}] ${p.filename} (${p.media_type}, ${p.size} bytes${O?"":" \u2014 not delivered"})`,m=(O,M,K)=>{i.push({ref:h,loc:g,media_type:O,...K?.blob?{blob:K.blob}:{},...K?.appearance?{appearance:K.appearance}:{},delivery:M,...K?.duplicate_of?{duplicate_of:K.duplicate_of}:{}})};if(!p.media_type.startsWith("image/")){m(p.media_type,"unsupported-vision-media-type"),c.push(d(!1));continue}let E=n.get(p.id);if(!E){m(p.media_type,"external-image-not-fetched"),c.push(d(!1));continue}let I;try{I=await e.fetchAttachment({id:p.id,download:E})}catch{m(p.media_type,"external-image-not-fetched"),c.push(d(!1));continue}let w=I.bytes,b=W(w),L=Qt[b.format],_=V(w);if(o.set(_,w),!en.has(b.format)){let O=b.format==="gif"||b.format==="bmp"||b.format==="tiff"?"unsupported-vision-media-type":"unsupported-image-kind";m(L,O,{blob:_}),c.push(d(!1));continue}if(b.width===void 0||b.height===void 0||b.width*b.height>Zt){m(L,"undecodable",{blob:_}),c.push(d(!1));continue}let T;if(b.format==="png"||b.format==="jpeg"){let O=H(w,b.format);if(O===null){m(L,"undecodable",{blob:_}),c.push(d(!1));continue}T=G(O.data,{width:O.width,height:O.height,channels:O.channels})}if(b.width<Xe||b.height<Xe){m(L,"below-dimension-floor",{blob:_,appearance:T}),c.push(d(!1));continue}let S=s.get(_);if(S!==void 0){m(L,"duplicate",{blob:_,appearance:T,duplicate_of:S}),c.push(d(!1));continue}if(w.byteLength>Xt){m(L,"image-too-large",{blob:_,appearance:T}),c.push(d(!1));continue}if(l+w.byteLength>qt){m(L,"vision-byte-budget-reached",{blob:_,appearance:T}),c.push(d(!1));continue}if(u.length>=zt){m(L,"image-cap-reached",{blob:_,appearance:T}),c.push(d(!1));continue}s.set(_,h),l+=w.byteLength,u.push(h),m(L,"selected",{blob:_,appearance:T}),c.push(d(!0))}let a=[];return a.push(`${r.title} \xB7 ${r.site} \xB7 ${r.space.key}`),r.labels.length>0&&a.push(`labels: ${r.labels.join(", ")}`),r.content.body!==""&&a.push("",...r.content.body.split(`
8
8
  `)),c.length>0&&a.push("","--- attachments ---",...c),{projection:a.join(`
9
9
  `)+`
10
- `,inventory:i,blobs:o,delivered:u,converter:{name:"confluence-convert",version:"1",policy:"v1"}}}}var tn=/^[A-Za-z0-9~][A-Za-z0-9._~-]*$/;function re(e){if(!/^https?:\/\/.+/i.test(e))return null;let n;try{n=new URL(e)}catch{return null}let t=n.pathname.split("/").filter(Boolean),r=t.indexOf("wiki");if(r===-1||t[r+1]!=="spaces"||t[r+3]!=="pages")return null;let i=t[r+2],o=t[r+4];return i===void 0||o===void 0||!tn.test(i)||!/^\d+$/.test(o)?null:{site:n.hostname,spaceKey:i,pageId:o}}async function qe(e,n,t){let r=t.lis??{jiraInfo:q,jiraIssue:Q,jiraAttachment:te,jiraComments:ee},i=t.confluence??{confluenceDocument:Le,confluenceAttachment:Ie};try{let u={auth:await(t.authEnv??(async()=>(await import("./auth-7Z54TMQQ.js")).resolveLisAuthEnv({credentials:t.credentials})))(),env:process.env},l=await r.jiraInfo(u);if(!l.installed)return{ok:!1,failure:{code:"NO_CONNECTION",message:`no Atlassian connection for this account \u2014 create one at ${A} and retry`}};if(l.capabilities.document===!1)return{ok:!1,failure:{code:"NO_CONFLUENCE_ACCESS",message:`the connection has no Confluence access \u2014 reconnect with Confluence at ${A} and retry`}};let s=await i.confluenceDocument(e.pageId,u),c=e.site;if(s.url)try{c=new URL(s.url).hostname}catch{}let{bytes:a,warnings:f}=ze(s,c),p=n??`page-${e.pageId}`;try{N(p)}catch(g){return{ok:!1,failure:{code:"BAD_SOURCE_ID",message:g instanceof Error?g.message:String(g)}}}let h=Object.fromEntries((s.attachments??[]).filter(g=>typeof g.download=="string"&&g.download.length>0).map(g=>[String(g.id),g.download]));return{ok:!0,bytes:a,site:c,sourceId:p,...s.title?{title:s.title}:{},warnings:f,downloads:h,remote:i,lisDeps:u}}catch(o){return o instanceof y?{ok:!1,failure:{code:o.code,message:o.message}}:{ok:!1,failure:{code:"FETCH_FAILED",message:tt(o instanceof Error?o.message:String(o))}}}}function Qe(e,n,t){let r=x(e,n,"confluence");if(r!==null)return{code:"KIND_MISMATCH",message:r,facts:{id:n,heldKind:J(e,n)??"",freeId:$(e,n)}};let i=fe(e,n);return i!==null&&i!==t?{code:"SITE_MOVED",message:v().text("note.site_moved",{source_id:n,previous:i,site:t}),facts:{id:n,freeId:$(e,n)}}:null}var et=(e,n,t)=>({confluence:Ze({downloads:e,fetchAttachment:r=>n.confluenceAttachment(r.download,t)})});async function nn(e,n,t,r,i){let o=re(e);if(o===null)return(t.err??t.out)(`error: ${e}: unsupported remote URL \u2014 expected a Confluence page URL (https://<site>/wiki/spaces/<KEY>/pages/<id>/\u2026)`),{code:1};let u=await qe(o,n,i);if(!u.ok)return(t.err??t.out)(`error: ${e}: ${u.failure.message}`),{code:1};let{bytes:l,site:s,sourceId:c,warnings:a,downloads:f,remote:p,lisDeps:h}=u;try{let g=Qe(r,c,s);if(g!==null)return(t.err??t.out)(`error: ${e}: ${g.message}`),{code:1};let d=await U({store:r,bytes:l,media:ae,sourceId:c,label:e,confirmSameSource:t.isTTY?m=>t.confirm(`identical content already ingested as ${m} \u2014 treat as the same source?`):void 0,converters:et(f,p,h)});t.out(B(t.isTTY,d,`${o.spaceKey}/${o.pageId}`));for(let m of a)t.out(`warning: ${m}`);for(let m of d.warnings??[])t.out(`warning: ${m}`);if(d.composite){let m=d.composite.delivered+d.composite.omitted;t.out(`${d.source_id}: confluence, ${m} attachments, ${d.composite.delivered} images delivered (${d.composite.omitted} omitted)`)}return{code:0,result:{status:d.status,source_id:d.source_id,source_cid:d.cid,...d.gitignore?{gitignore:d.gitignore}:{}}}}catch(g){return g instanceof y?((t.err??t.out)(`error: ${e}: ${g.message}`),{code:1}):((t.err??t.out)(`error: ${e}: ${tt(g instanceof Error?g.message:String(g))}`),{code:1})}}async function rn(e,n,t){let r=re(e);if(r===null)return{ok:!1,failure:{code:"UNSUPPORTED_URL",message:"unsupported remote URL \u2014 expected a Confluence page URL (https://<site>/wiki/spaces/<KEY>/pages/<id>/\u2026)"}};if(n!==void 0&&!D(n))return{ok:!1,failure:{code:"BAD_SOURCE_ID",message:j(n)}};let i=await qe(r,n,t);return i.ok?{ok:!0,fetched:{provider:"confluence",sourceId:i.sourceId,bytes:i.bytes,media:ae,label:e,display:`${r.spaceKey}/${r.pageId}`,...i.title?{title:i.title}:{},origin:{kind:"confluence",url:e},identity:{site:i.site},warnings:i.warnings,downloads:i.downloads}}:i}async function on(e,n,t){let r=Qe(n,e.sourceId,e.identity.site??"");if(r!==null)return{ok:!1,failure:r};let i=t.confluence??{confluenceDocument:Le,confluenceAttachment:Ie},u={auth:await(t.authEnv??(async()=>(await import("./auth-7Z54TMQQ.js")).resolveLisAuthEnv({credentials:t.credentials})))(),env:process.env};return{ok:!0,media:ae,label:e.label,converters:et(e.downloads??{},i,u)}}function tt(e){let n=e.match(/too large — ([\d.]+ [KM]B), the limit for .+ is ([\d.]+ [KM]B) \[FILE_TOO_LARGE\]/);return n?`the page's content is too large to ingest (${n[1]}; the limit is ${n[2]}) \u2014 trim the page in Confluence and retry`:e.startsWith("PROJECTION_TOO_LARGE:")?"the page's text is too large to ingest \u2014 trim the page in Confluence and retry":e}var nt={name:"confluence",hint:"Confluence page URLs (https://<site>/wiki/spaces/<KEY>/pages/<id>/\u2026)",match:e=>re(e)!==null,ingest:nn,sourceIdFor:e=>{let n=re(e);return n?`page-${n.pageId}`:null},fetch:rn,prepare:on};async function rt(e={}){let n=await k("/linear-app/info",{method:"GET"},e);if(!n.ok)throw R(n,"the connection","Linear");let t=P(n);return{installed:t.data?.INSTALLED==="YES",capabilities:{issue:t.data?.capabilities?.issue===!0,comments:t.data?.capabilities?.comments===!0,document:t.data?.capabilities?.document===!0}}}async function it(e,n={}){let t=await k("/linear-app/issue?details=true",{method:"POST",body:JSON.stringify({plugin_code:"linear-app",issueKey:e})},n);if(!t.ok)throw R(t,"the issue","Linear");let r=P(t);if(r.type==="error"||!r.data)throw new y("JIRA_ISSUE_UNAVAILABLE",`could not fetch the issue: ${C(r.message??"")||"issue not found or not accessible"}`);return r.data}var sn=100,an=5e3,cn=60;async function ot(e,n={}){let t=[],r=new Set,i=null;for(let o=0;;o++){if(o>=cn)throw new y("LIS_UNAVAILABLE","the integrations service kept returning comment pages without finishing \u2014 retry later");let u=await k("/linear-app/issue/comments",{method:"POST",body:JSON.stringify({resource_id:e,max_results:sn,...i===null?{}:{cursor:i},fetch_all:!1})},n);if(!u.ok)throw R(u,"the issue's comments","Linear");let l=P(u);if(l.type==="error"||!l.data)throw new y("JIRA_ISSUE_UNAVAILABLE",`could not fetch the issue's comments: ${C(l.message??"")||"unavailable"}`);if(l.data.partial)throw new y("JIRA_ISSUE_UNAVAILABLE","the integrations service returned an incomplete comment set \u2014 retry later");for(let a of l.data.comments??[]){if(typeof a.id!="string"||a.id==="")throw new y("JIRA_ISSUE_UNAVAILABLE","the integrations service returned an incomplete comment set \u2014 a comment row has no comment id");r.has(a.id)||(r.add(a.id),t.push(a))}let s=l.data.pagination;if(!s?.has_more)return t;if(t.length>=an)throw new y("JIRA_ISSUE_UNAVAILABLE","the issue has more comments than can be ingested \u2014 cannot build a complete identity");let c=s.next_cursor??null;if(c==null||c===i)throw new y("LIS_UNAVAILABLE","the integrations service returned a non-advancing comments page \u2014 retry later");i=c}}async function st(e,n={}){let t=await k("/linear-app/document",{method:"POST",body:JSON.stringify({resource_id:e,format:"markdown"})},n);if(!t.ok)throw R(t,"the document","Linear");let r=P(t);if(r.type==="error"||!r.data)throw new y("JIRA_ISSUE_UNAVAILABLE",`could not fetch the document: ${C(r.message??"")||"document not found or not accessible"}`);return r.data}async function at(e,n={}){let t=await k("/linear-app/attachment",{method:"POST",body:JSON.stringify({attachment_id:e})},n);if(!t.ok)throw R(t,"the attachment","Linear");return{bytes:Y(t).bytes}}var ge="kane.source.linear/1",he="kane.source.linear-doc/1",un=/https:\/\/uploads\.linear\.app\/[^\s)"'`]+/g;function z(e){return e.replace(un,n=>{let t=n.indexOf("?");return t===-1?n:n.slice(0,t)})}function ct(e,n){return e.id<n.id?-1:e.id>n.id?1:0}function ln(e,n){return ct(e,n)||(e.filename<n.filename?-1:e.filename>n.filename?1:0)||(e.url<n.url?-1:e.url>n.url?1:0)}function ut(e,n,t){if(typeof e.id!="string"||e.id==="")throw new Error("cannot build a stable identity for this issue \u2014 the integrations service returned no issue id");let r=e.key;if(!/^[A-Za-z][A-Za-z0-9]*-\d+$/.test(r)){let c=String(r).replace(/[\u0000-\u001f\u007f-\u009f]/g,"").slice(0,80);throw new Error(`cannot build a stable identity for issue key "${c}" \u2014 expected a TEAM-NUMBER key`)}let i={},o=[...e.labels??[]].filter(c=>typeof c=="string").sort();o.length>0&&(i.labels=o.join(", ")),typeof e.priority=="string"&&e.priority!==""&&(i.priority=e.priority),typeof e.project=="string"&&e.project!==""&&(i.project=e.project),typeof e.status=="string"&&e.status!==""&&(i.status=e.status);let u=(e.attachments??[]).map(c=>({id:c.id!=null&&String(c.id)!==""?String(c.id):z(c.download??""),filename:c.filename??"",url:z(c.download??"")})).sort(ln),l=n.map(c=>({id:String(c.id),author:c.author?.display_name??"",body:z(c.body??""),created:c.created??""})).sort((c,a)=>c.created!==a.created?c.created<a.created?-1:1:ct(c,a)),s={schema:ge,site:t,team:r.slice(0,r.lastIndexOf("-")),issue:{uuid:e.id,key:r},content:{title:e.summary??"",description:z(e.description??""),fields:i},attachments:u,comments:l};return{bytes:Buffer.from(JSON.stringify(s),"utf8"),envelope:s,warnings:[]}}function lt(e,n,t){if(typeof e.id!="string"||e.id==="")throw new Error("cannot build a stable identity for this document \u2014 the integrations service returned no document id");let r=(e.attachments??[]).map(o=>({url:z(o.download??String(o.id??"")),filename:o.filename??""})).sort((o,u)=>o.url<u.url?-1:o.url>u.url?1:0),i={schema:he,site:n,document:{uuid:e.id,slug_id:t},project:{id:e.space?.key??""},title:e.title??"",content:{body:z(e.body??"")},attachments:r};return{bytes:Buffer.from(JSON.stringify(i),"utf8"),envelope:i,warnings:[]}}var dt=64,dn=16,pn=6e6,fn=5e7,mn=12e6,ye=64,pt="https://uploads.linear.app/",gn=/https:\/\/uploads\.linear\.app\/[^\s)"'`]+/g,hn={png:"image/png",jpeg:"image/jpeg",webp:"image/webp",gif:"image/gif",bmp:"image/bmp",tiff:"image/tiff",emf:"image/emf",wmf:"image/wmf",unknown:"application/octet-stream"},yn=new Set(["png","jpeg","webp"]);async function ft(e,n){let t=[],r=new Map,i=[],o=0,u=new Map,l=[];for(let s=0;s<e.length;s++){let c=e[s],a=`i${s+1}`,f=b=>`[img#${a}] ${c.label}${b?"":" \u2014 not delivered"}`,p=(b,L,_)=>{t.push({ref:a,loc:c.loc,media_type:b,..._?.blob?{blob:_.blob}:{},..._?.appearance?{appearance:_.appearance}:{},delivery:L,..._?.duplicate_of?{duplicate_of:_.duplicate_of}:{}})},h;try{h=await n(c.url)}catch{p("application/octet-stream","external-image-not-fetched"),l.push(f(!1));continue}let g=h.bytes,d=W(g),m=hn[d.format],E=V(g);if(r.set(E,g),!yn.has(d.format)){let b=d.format==="gif"||d.format==="bmp"||d.format==="tiff"?"unsupported-vision-media-type":"unsupported-image-kind";p(m,b,{blob:E}),l.push(f(!1));continue}if(d.width===void 0||d.height===void 0||d.width*d.height>fn){p(m,"undecodable",{blob:E}),l.push(f(!1));continue}let I;if(d.format==="png"||d.format==="jpeg"){let b=H(g,d.format);if(b===null){p(m,"undecodable",{blob:E}),l.push(f(!1));continue}I=G(b.data,{width:b.width,height:b.height,channels:b.channels})}if(d.width<dt||d.height<dt){p(m,"below-dimension-floor",{blob:E,appearance:I}),l.push(f(!1));continue}let w=u.get(E);if(w!==void 0){p(m,"duplicate",{blob:E,appearance:I,duplicate_of:w}),l.push(f(!1));continue}if(g.byteLength>pn){p(m,"image-too-large",{blob:E,appearance:I}),l.push(f(!1));continue}if(o+g.byteLength>mn){p(m,"vision-byte-budget-reached",{blob:E,appearance:I}),l.push(f(!1));continue}if(i.length>=dn){p(m,"image-cap-reached",{blob:E,appearance:I}),l.push(f(!1));continue}u.set(E,a),o+=g.byteLength,i.push(a),p(m,"selected",{blob:E,appearance:I}),l.push(f(!0))}return{inventory:t,blobs:r,delivered:i,lines:l}}function En(e){let n=new Set,t=[];for(let r of e.match(gn)??[])n.has(r)||(n.add(r),t.push(r));return t}function ve(e){return async n=>{let t;try{t=JSON.parse(n.toString("utf8"))}catch{throw new Error("LINEAR_ENVELOPE_SCHEMA: source bytes are not a kane linear envelope")}if(t.schema!==ge)throw new Error(`LINEAR_ENVELOPE_SCHEMA: unknown envelope schema "${t.schema}" \u2014 this CLI understands ${ge}`);let r=[],i=new Set;for(let a of En(t.content.description))i.add(a),r.push({url:a,label:a,loc:`body:${a}`});let o=[];for(let a of t.attachments)if(a.url.startsWith(pt)){if(i.has(a.url)){if(a.filename!==""){let f=r.find(p=>p.url===a.url);f!==void 0&&f.label===f.url&&(f.label=a.filename)}continue}i.add(a.url),r.push({url:a.url,label:a.filename||a.url,loc:`attachment:${a.filename||a.url}`})}else a.url!==""&&o.push(`[${o.length+1}] ${a.filename||a.url} \u2014 ${a.url}`);let u=Math.max(0,r.length-ye),l=await ft(r.slice(0,ye),e.fetchAttachment);u>0&&l.lines.push(`${u} more upload links not examined`);let s=[];s.push(`${t.issue.key} \xB7 ${t.site}`,`Title: ${t.content.title}`),t.content.description!==""&&s.push("",...t.content.description.split(`
10
+ `,inventory:i,blobs:o,delivered:u,converter:{name:"confluence-convert",version:"1",policy:"v1"}}}}var tn=/^[A-Za-z0-9~][A-Za-z0-9._~-]*$/;function re(e){if(!/^https?:\/\/.+/i.test(e))return null;let n;try{n=new URL(e)}catch{return null}let t=n.pathname.split("/").filter(Boolean),r=t.indexOf("wiki");if(r===-1||t[r+1]!=="spaces"||t[r+3]!=="pages")return null;let i=t[r+2],o=t[r+4];return i===void 0||o===void 0||!tn.test(i)||!/^\d+$/.test(o)?null:{site:n.hostname,spaceKey:i,pageId:o}}async function qe(e,n,t){let r=t.lis??{jiraInfo:q,jiraIssue:Q,jiraAttachment:te,jiraComments:ee},i=t.confluence??{confluenceDocument:Le,confluenceAttachment:Ie};try{let u={auth:await(t.authEnv??(async()=>(await import("./auth-WBIEHHDS.js")).resolveLisAuthEnv({credentials:t.credentials})))(),env:process.env},l=await r.jiraInfo(u);if(!l.installed)return{ok:!1,failure:{code:"NO_CONNECTION",message:`no Atlassian connection for this account \u2014 create one at ${A} and retry`}};if(l.capabilities.document===!1)return{ok:!1,failure:{code:"NO_CONFLUENCE_ACCESS",message:`the connection has no Confluence access \u2014 reconnect with Confluence at ${A} and retry`}};let s=await i.confluenceDocument(e.pageId,u),c=e.site;if(s.url)try{c=new URL(s.url).hostname}catch{}let{bytes:a,warnings:f}=ze(s,c),p=n??`page-${e.pageId}`;try{N(p)}catch(g){return{ok:!1,failure:{code:"BAD_SOURCE_ID",message:g instanceof Error?g.message:String(g)}}}let h=Object.fromEntries((s.attachments??[]).filter(g=>typeof g.download=="string"&&g.download.length>0).map(g=>[String(g.id),g.download]));return{ok:!0,bytes:a,site:c,sourceId:p,...s.title?{title:s.title}:{},warnings:f,downloads:h,remote:i,lisDeps:u}}catch(o){return o instanceof y?{ok:!1,failure:{code:o.code,message:o.message}}:{ok:!1,failure:{code:"FETCH_FAILED",message:tt(o instanceof Error?o.message:String(o))}}}}function Qe(e,n,t){let r=x(e,n,"confluence");if(r!==null)return{code:"KIND_MISMATCH",message:r,facts:{id:n,heldKind:J(e,n)??"",freeId:$(e,n)}};let i=fe(e,n);return i!==null&&i!==t?{code:"SITE_MOVED",message:v().text("note.site_moved",{source_id:n,previous:i,site:t}),facts:{id:n,freeId:$(e,n)}}:null}var et=(e,n,t)=>({confluence:Ze({downloads:e,fetchAttachment:r=>n.confluenceAttachment(r.download,t)})});async function nn(e,n,t,r,i){let o=re(e);if(o===null)return(t.err??t.out)(`error: ${e}: unsupported remote URL \u2014 expected a Confluence page URL (https://<site>/wiki/spaces/<KEY>/pages/<id>/\u2026)`),{code:1};let u=await qe(o,n,i);if(!u.ok)return(t.err??t.out)(`error: ${e}: ${u.failure.message}`),{code:1};let{bytes:l,site:s,sourceId:c,warnings:a,downloads:f,remote:p,lisDeps:h}=u;try{let g=Qe(r,c,s);if(g!==null)return(t.err??t.out)(`error: ${e}: ${g.message}`),{code:1};let d=await U({store:r,bytes:l,media:ae,sourceId:c,label:e,confirmSameSource:t.isTTY?m=>t.confirm(`identical content already ingested as ${m} \u2014 treat as the same source?`):void 0,converters:et(f,p,h)});t.out(B(t.isTTY,d,`${o.spaceKey}/${o.pageId}`));for(let m of a)t.out(`warning: ${m}`);for(let m of d.warnings??[])t.out(`warning: ${m}`);if(d.composite){let m=d.composite.delivered+d.composite.omitted;t.out(`${d.source_id}: confluence, ${m} attachments, ${d.composite.delivered} images delivered (${d.composite.omitted} omitted)`)}return{code:0,result:{status:d.status,source_id:d.source_id,source_cid:d.cid,...d.gitignore?{gitignore:d.gitignore}:{}}}}catch(g){return g instanceof y?((t.err??t.out)(`error: ${e}: ${g.message}`),{code:1}):((t.err??t.out)(`error: ${e}: ${tt(g instanceof Error?g.message:String(g))}`),{code:1})}}async function rn(e,n,t){let r=re(e);if(r===null)return{ok:!1,failure:{code:"UNSUPPORTED_URL",message:"unsupported remote URL \u2014 expected a Confluence page URL (https://<site>/wiki/spaces/<KEY>/pages/<id>/\u2026)"}};if(n!==void 0&&!D(n))return{ok:!1,failure:{code:"BAD_SOURCE_ID",message:j(n)}};let i=await qe(r,n,t);return i.ok?{ok:!0,fetched:{provider:"confluence",sourceId:i.sourceId,bytes:i.bytes,media:ae,label:e,display:`${r.spaceKey}/${r.pageId}`,...i.title?{title:i.title}:{},origin:{kind:"confluence",url:e},identity:{site:i.site},warnings:i.warnings,downloads:i.downloads}}:i}async function on(e,n,t){let r=Qe(n,e.sourceId,e.identity.site??"");if(r!==null)return{ok:!1,failure:r};let i=t.confluence??{confluenceDocument:Le,confluenceAttachment:Ie},u={auth:await(t.authEnv??(async()=>(await import("./auth-WBIEHHDS.js")).resolveLisAuthEnv({credentials:t.credentials})))(),env:process.env};return{ok:!0,media:ae,label:e.label,converters:et(e.downloads??{},i,u)}}function tt(e){let n=e.match(/too large — ([\d.]+ [KM]B), the limit for .+ is ([\d.]+ [KM]B) \[FILE_TOO_LARGE\]/);return n?`the page's content is too large to ingest (${n[1]}; the limit is ${n[2]}) \u2014 trim the page in Confluence and retry`:e.startsWith("PROJECTION_TOO_LARGE:")?"the page's text is too large to ingest \u2014 trim the page in Confluence and retry":e}var nt={name:"confluence",hint:"Confluence page URLs (https://<site>/wiki/spaces/<KEY>/pages/<id>/\u2026)",match:e=>re(e)!==null,ingest:nn,sourceIdFor:e=>{let n=re(e);return n?`page-${n.pageId}`:null},fetch:rn,prepare:on};async function rt(e={}){let n=await k("/linear-app/info",{method:"GET"},e);if(!n.ok)throw R(n,"the connection","Linear");let t=P(n);return{installed:t.data?.INSTALLED==="YES",capabilities:{issue:t.data?.capabilities?.issue===!0,comments:t.data?.capabilities?.comments===!0,document:t.data?.capabilities?.document===!0}}}async function it(e,n={}){let t=await k("/linear-app/issue?details=true",{method:"POST",body:JSON.stringify({plugin_code:"linear-app",issueKey:e})},n);if(!t.ok)throw R(t,"the issue","Linear");let r=P(t);if(r.type==="error"||!r.data)throw new y("JIRA_ISSUE_UNAVAILABLE",`could not fetch the issue: ${C(r.message??"")||"issue not found or not accessible"}`);return r.data}var sn=100,an=5e3,cn=60;async function ot(e,n={}){let t=[],r=new Set,i=null;for(let o=0;;o++){if(o>=cn)throw new y("LIS_UNAVAILABLE","the integrations service kept returning comment pages without finishing \u2014 retry later");let u=await k("/linear-app/issue/comments",{method:"POST",body:JSON.stringify({resource_id:e,max_results:sn,...i===null?{}:{cursor:i},fetch_all:!1})},n);if(!u.ok)throw R(u,"the issue's comments","Linear");let l=P(u);if(l.type==="error"||!l.data)throw new y("JIRA_ISSUE_UNAVAILABLE",`could not fetch the issue's comments: ${C(l.message??"")||"unavailable"}`);if(l.data.partial)throw new y("JIRA_ISSUE_UNAVAILABLE","the integrations service returned an incomplete comment set \u2014 retry later");for(let a of l.data.comments??[]){if(typeof a.id!="string"||a.id==="")throw new y("JIRA_ISSUE_UNAVAILABLE","the integrations service returned an incomplete comment set \u2014 a comment row has no comment id");r.has(a.id)||(r.add(a.id),t.push(a))}let s=l.data.pagination;if(!s?.has_more)return t;if(t.length>=an)throw new y("JIRA_ISSUE_UNAVAILABLE","the issue has more comments than can be ingested \u2014 cannot build a complete identity");let c=s.next_cursor??null;if(c==null||c===i)throw new y("LIS_UNAVAILABLE","the integrations service returned a non-advancing comments page \u2014 retry later");i=c}}async function st(e,n={}){let t=await k("/linear-app/document",{method:"POST",body:JSON.stringify({resource_id:e,format:"markdown"})},n);if(!t.ok)throw R(t,"the document","Linear");let r=P(t);if(r.type==="error"||!r.data)throw new y("JIRA_ISSUE_UNAVAILABLE",`could not fetch the document: ${C(r.message??"")||"document not found or not accessible"}`);return r.data}async function at(e,n={}){let t=await k("/linear-app/attachment",{method:"POST",body:JSON.stringify({attachment_id:e})},n);if(!t.ok)throw R(t,"the attachment","Linear");return{bytes:Y(t).bytes}}var ge="kane.source.linear/1",he="kane.source.linear-doc/1",un=/https:\/\/uploads\.linear\.app\/[^\s)"'`]+/g;function z(e){return e.replace(un,n=>{let t=n.indexOf("?");return t===-1?n:n.slice(0,t)})}function ct(e,n){return e.id<n.id?-1:e.id>n.id?1:0}function ln(e,n){return ct(e,n)||(e.filename<n.filename?-1:e.filename>n.filename?1:0)||(e.url<n.url?-1:e.url>n.url?1:0)}function ut(e,n,t){if(typeof e.id!="string"||e.id==="")throw new Error("cannot build a stable identity for this issue \u2014 the integrations service returned no issue id");let r=e.key;if(!/^[A-Za-z][A-Za-z0-9]*-\d+$/.test(r)){let c=String(r).replace(/[\u0000-\u001f\u007f-\u009f]/g,"").slice(0,80);throw new Error(`cannot build a stable identity for issue key "${c}" \u2014 expected a TEAM-NUMBER key`)}let i={},o=[...e.labels??[]].filter(c=>typeof c=="string").sort();o.length>0&&(i.labels=o.join(", ")),typeof e.priority=="string"&&e.priority!==""&&(i.priority=e.priority),typeof e.project=="string"&&e.project!==""&&(i.project=e.project),typeof e.status=="string"&&e.status!==""&&(i.status=e.status);let u=(e.attachments??[]).map(c=>({id:c.id!=null&&String(c.id)!==""?String(c.id):z(c.download??""),filename:c.filename??"",url:z(c.download??"")})).sort(ln),l=n.map(c=>({id:String(c.id),author:c.author?.display_name??"",body:z(c.body??""),created:c.created??""})).sort((c,a)=>c.created!==a.created?c.created<a.created?-1:1:ct(c,a)),s={schema:ge,site:t,team:r.slice(0,r.lastIndexOf("-")),issue:{uuid:e.id,key:r},content:{title:e.summary??"",description:z(e.description??""),fields:i},attachments:u,comments:l};return{bytes:Buffer.from(JSON.stringify(s),"utf8"),envelope:s,warnings:[]}}function lt(e,n,t){if(typeof e.id!="string"||e.id==="")throw new Error("cannot build a stable identity for this document \u2014 the integrations service returned no document id");let r=(e.attachments??[]).map(o=>({url:z(o.download??String(o.id??"")),filename:o.filename??""})).sort((o,u)=>o.url<u.url?-1:o.url>u.url?1:0),i={schema:he,site:n,document:{uuid:e.id,slug_id:t},project:{id:e.space?.key??""},title:e.title??"",content:{body:z(e.body??"")},attachments:r};return{bytes:Buffer.from(JSON.stringify(i),"utf8"),envelope:i,warnings:[]}}var dt=64,dn=16,pn=6e6,fn=5e7,mn=12e6,ye=64,pt="https://uploads.linear.app/",gn=/https:\/\/uploads\.linear\.app\/[^\s)"'`]+/g,hn={png:"image/png",jpeg:"image/jpeg",webp:"image/webp",gif:"image/gif",bmp:"image/bmp",tiff:"image/tiff",emf:"image/emf",wmf:"image/wmf",unknown:"application/octet-stream"},yn=new Set(["png","jpeg","webp"]);async function ft(e,n){let t=[],r=new Map,i=[],o=0,u=new Map,l=[];for(let s=0;s<e.length;s++){let c=e[s],a=`i${s+1}`,f=b=>`[img#${a}] ${c.label}${b?"":" \u2014 not delivered"}`,p=(b,L,_)=>{t.push({ref:a,loc:c.loc,media_type:b,..._?.blob?{blob:_.blob}:{},..._?.appearance?{appearance:_.appearance}:{},delivery:L,..._?.duplicate_of?{duplicate_of:_.duplicate_of}:{}})},h;try{h=await n(c.url)}catch{p("application/octet-stream","external-image-not-fetched"),l.push(f(!1));continue}let g=h.bytes,d=W(g),m=hn[d.format],E=V(g);if(r.set(E,g),!yn.has(d.format)){let b=d.format==="gif"||d.format==="bmp"||d.format==="tiff"?"unsupported-vision-media-type":"unsupported-image-kind";p(m,b,{blob:E}),l.push(f(!1));continue}if(d.width===void 0||d.height===void 0||d.width*d.height>fn){p(m,"undecodable",{blob:E}),l.push(f(!1));continue}let I;if(d.format==="png"||d.format==="jpeg"){let b=H(g,d.format);if(b===null){p(m,"undecodable",{blob:E}),l.push(f(!1));continue}I=G(b.data,{width:b.width,height:b.height,channels:b.channels})}if(d.width<dt||d.height<dt){p(m,"below-dimension-floor",{blob:E,appearance:I}),l.push(f(!1));continue}let w=u.get(E);if(w!==void 0){p(m,"duplicate",{blob:E,appearance:I,duplicate_of:w}),l.push(f(!1));continue}if(g.byteLength>pn){p(m,"image-too-large",{blob:E,appearance:I}),l.push(f(!1));continue}if(o+g.byteLength>mn){p(m,"vision-byte-budget-reached",{blob:E,appearance:I}),l.push(f(!1));continue}if(i.length>=dn){p(m,"image-cap-reached",{blob:E,appearance:I}),l.push(f(!1));continue}u.set(E,a),o+=g.byteLength,i.push(a),p(m,"selected",{blob:E,appearance:I}),l.push(f(!0))}return{inventory:t,blobs:r,delivered:i,lines:l}}function En(e){let n=new Set,t=[];for(let r of e.match(gn)??[])n.has(r)||(n.add(r),t.push(r));return t}function ve(e){return async n=>{let t;try{t=JSON.parse(n.toString("utf8"))}catch{throw new Error("LINEAR_ENVELOPE_SCHEMA: source bytes are not a kane linear envelope")}if(t.schema!==ge)throw new Error(`LINEAR_ENVELOPE_SCHEMA: unknown envelope schema "${t.schema}" \u2014 this CLI understands ${ge}`);let r=[],i=new Set;for(let a of En(t.content.description))i.add(a),r.push({url:a,label:a,loc:`body:${a}`});let o=[];for(let a of t.attachments)if(a.url.startsWith(pt)){if(i.has(a.url)){if(a.filename!==""){let f=r.find(p=>p.url===a.url);f!==void 0&&f.label===f.url&&(f.label=a.filename)}continue}i.add(a.url),r.push({url:a.url,label:a.filename||a.url,loc:`attachment:${a.filename||a.url}`})}else a.url!==""&&o.push(`[${o.length+1}] ${a.filename||a.url} \u2014 ${a.url}`);let u=Math.max(0,r.length-ye),l=await ft(r.slice(0,ye),e.fetchAttachment);u>0&&l.lines.push(`${u} more upload links not examined`);let s=[];s.push(`${t.issue.key} \xB7 ${t.site}`,`Title: ${t.content.title}`),t.content.description!==""&&s.push("",...t.content.description.split(`
11
11
  `));let c=Object.keys(t.content.fields);return c.length>0&&s.push("","--- fields ---",...c.map(a=>`${a}: ${t.content.fields[a]}`)),l.lines.length>0&&s.push("","--- images ---",...l.lines),o.length>0&&s.push("","--- links ---",...o),t.comments.length>0&&(s.push("","--- comments ---"),t.comments.forEach((a,f)=>{f>0&&s.push(""),s.push(`[${f+1}] ${a.author} \xB7 ${a.created}`,...a.body.split(`
12
12
  `))})),{projection:s.join(`
13
13
  `)+`
14
14
  `,inventory:l.inventory,blobs:l.blobs,delivered:l.delivered,converter:{name:"linear-convert",version:"1",policy:"v1"}}}}function Ae(e){return async n=>{let t;try{t=JSON.parse(n.toString("utf8"))}catch{throw new Error("LINEAR_DOC_ENVELOPE_SCHEMA: source bytes are not a kane linear document envelope")}if(t.schema!==he)throw new Error(`LINEAR_DOC_ENVELOPE_SCHEMA: unknown envelope schema "${t.schema}" \u2014 this CLI understands ${he}`);let r=new Set,i=[];for(let s of t.attachments)!s.url.startsWith(pt)||r.has(s.url)||(r.add(s.url),i.push({url:s.url,label:s.filename||s.url,loc:`body:${s.url}`}));let o=Math.max(0,i.length-ye),u=await ft(i.slice(0,ye),e.fetchAttachment);o>0&&u.lines.push(`${o} more upload links not examined`);let l=[];return l.push(`${t.title} \xB7 ${t.site}`),t.content.body!==""&&l.push("",...t.content.body.split(`
15
15
  `)),u.lines.length>0&&l.push("","--- images ---",...u.lines),{projection:l.join(`
16
16
  `)+`
17
- `,inventory:u.inventory,blobs:u.blobs,delivered:u.delivered,converter:{name:"linear-doc-convert",version:"1",policy:"v1"}}}}var bn=/^[A-Za-z][A-Za-z0-9]*-\d+$/,_n=/-([0-9a-f]{12})$/;function Se(e){if(!/^https?:\/\/.+/i.test(e))return null;let n;try{n=new URL(e)}catch{return null}return n.hostname.toLowerCase()!=="linear.app"?null:n.pathname.split("/").filter(Boolean)}function mt(e){let n=Se(e);return n===null||n.length<3?null:{workspace:n[0],segs:n}}function X(e){let n=mt(e);if(n===null||n.segs[1]!=="issue")return null;let t=n.segs[2];return bn.test(t)?{workspace:n.workspace,key:t}:null}function Z(e){let n=mt(e);if(n===null||n.segs[1]!=="document")return null;let t=n.segs[2].match(_n);return t===null?null:{workspace:n.workspace,slugId:t[1]}}var wn=new Set(["project","team","view","initiative","cycle","roadmap","inbox","triage","my-issues"]),gt=new Set(["docs","features","method","blog","customers","pricing","integrations","developers","changelog","about","careers","security","download","contact","now","switch","homepage"]);function Re(e){let n=Se(e);return n===null||n.length<2||!wn.has(n[1])||gt.has(n[0].toLowerCase())?null:{workspace:n[0],section:n[1]}}function ke(e){let n=Se(e);return n===null||n.length<2||n[1]!=="issue"&&n[1]!=="document"||gt.has(n[0].toLowerCase())||X(e)!==null||Z(e)!==null?null:{workspace:n[0],section:n[1]}}function ht(e){let n=X(e);return n?n.key.toLowerCase():null}function yt(e){let n=Z(e);return n?`doc-${n.slugId}`:null}var Oe={linearInfo:rt,linearIssue:it,linearComments:ot,linearDocument:st,linearAttachment:at};function bt(e,n){if(e)try{let t=new URL(e).pathname.split("/").filter(Boolean)[0];if(t)return`linear.app/${t.toLowerCase()}`}catch{}return`linear.app/${n.toLowerCase()}`}function Ln(e,n,t,r,i,o){let u=pe(e,r);if(u!==null&&typeof u.schema=="string"&&u.schema.startsWith(`kane.source.${n}/`)){let s=u;for(let c of t)s=s!==null&&typeof s=="object"?s[c]:void 0;if(typeof s=="string"&&s!==""&&s!==i)return v().text("note.key_recycled",{source_id:r,what:o})}let l=we(e,n,t,i);return l!==null&&l!==r?`this ${o} is already ingested as '${l}' (its key changed) \u2014 reconcile that source, or retire it to re-ingest under the new key`:null}function In(e,n,t,r){let i=pe(e,t);if(i===null||typeof i.schema!="string"||!i.schema.startsWith(`kane.source.${n}/`))return null;let o=i.site;return typeof o!="string"||o.length===0||o===r?null:v().text("note.site_moved",{source_id:t,previous:o,site:r})}function Ce(e,n,t,r,i,o,u){let l=Ln(e,n,t,r,i,o);if(l!==null){let a=we(e,n,t,i);return{code:"UUID_MOVED",message:l,facts:a!==null&&a!==r?{holder:a}:{id:r,freeId:$(e,r)}}}let s=x(e,r,n);if(s!==null)return{code:"KIND_MISMATCH",message:s,facts:{id:r,heldKind:J(e,r)??"",freeId:$(e,r)}};let c=In(e,n,r,u);return c!==null?{code:"SITE_MOVED",message:c,facts:{id:r,freeId:$(e,r)}}:null}var _t=(e,n)=>e instanceof y?{code:e.code,message:e.message}:{code:"FETCH_FAILED",message:$e(e instanceof Error?e.message:String(e),n,"Linear")};async function wt(e,n,t){let r=t.linear??Oe;try{let o={auth:await(t.authEnv??(async()=>(await import("./auth-7Z54TMQQ.js")).resolveLisAuthEnv({credentials:t.credentials})))(),env:process.env},u=await r.linearInfo(o);if(!u.installed)return{ok:!1,failure:{code:"NO_CONNECTION",message:`no Linear connection for this account \u2014 create one at ${A} and retry`}};if(u.capabilities.issue===!1||u.capabilities.comments===!1)return{ok:!1,failure:{code:"NO_ISSUE_ACCESS",message:`the connection cannot read issues or their comments yet \u2014 resync it at ${A} and retry`}};let l=await r.linearIssue(e.key,o),s=await r.linearComments(e.key,o),c=bt(l.host,e.workspace),{bytes:a,envelope:f,warnings:p}=ut(l,s,c),h=n??e.key.toLowerCase();try{N(h)}catch(g){return{ok:!1,failure:{code:"BAD_SOURCE_ID",message:g instanceof Error?g.message:String(g)}}}return{ok:!0,bytes:a,key:f.issue.key,uuid:f.issue.uuid,site:c,sourceId:h,warnings:p,lis:r,lisDeps:o}}catch(i){return{ok:!1,failure:_t(i,"issue")}}}async function Lt(e,n,t){let r=t.linear??Oe;try{let o={auth:await(t.authEnv??(async()=>(await import("./auth-7Z54TMQQ.js")).resolveLisAuthEnv({credentials:t.credentials})))(),env:process.env},u=await r.linearInfo(o);if(!u.installed)return{ok:!1,failure:{code:"NO_CONNECTION",message:`no Linear connection for this account \u2014 create one at ${A} and retry`}};if(u.capabilities.document===!1)return{ok:!1,failure:{code:"NO_DOCUMENT_ACCESS",message:`the connection cannot read documents yet \u2014 resync it at ${A} and retry`}};let l=await r.linearDocument(e.slugId,o),s=bt(l.url,e.workspace),{bytes:c,envelope:a,warnings:f}=lt(l,s,e.slugId),p=n??`doc-${e.slugId}`;try{N(p)}catch(h){return{ok:!1,failure:{code:"BAD_SOURCE_ID",message:h instanceof Error?h.message:String(h)}}}return{ok:!0,bytes:c,title:a.title||`document ${e.slugId}`,uuid:a.document.uuid,site:s,sourceId:p,warnings:f,lis:r,lisDeps:o}}catch(i){return{ok:!1,failure:_t(i,"document")}}}async function vn(e,n,t,r,i){let o=X(e);if(o===null)return(t.err??t.out)(`error: ${e}: unsupported remote URL \u2014 expected a Linear issue URL (https://linear.app/<workspace>/issue/KEY-123)`),{code:1};let u=await wt(o,n,i);if(!u.ok)return(t.err??t.out)(`error: ${e}: ${u.failure.message}`),{code:1};let{bytes:l,key:s,uuid:c,site:a,sourceId:f,warnings:p,lis:h,lisDeps:g}=u;try{let d=Ce(r,"linear",["issue","uuid"],f,c,"issue",a);if(d!==null)return(t.err??t.out)(`error: ${e}: ${d.message}`),{code:1};let m=await U({store:r,bytes:l,media:ue,sourceId:f,label:e,confirmSameSource:t.isTTY?E=>t.confirm(`identical content already ingested as ${E} \u2014 treat as the same source?`):void 0,converters:{linear:ve({fetchAttachment:E=>h.linearAttachment(E,g)})}});t.out(B(t.isTTY,m,s));for(let E of p)t.out(`warning: ${E}`);for(let E of m.warnings??[])t.out(`warning: ${E}`);if(m.composite){let E=m.composite.delivered+m.composite.omitted;t.out(`${m.source_id}: linear, ${E} images, ${m.composite.delivered} delivered (${m.composite.omitted} omitted)`)}return{code:0,result:{status:m.status,source_id:m.source_id,source_cid:m.cid,...m.gitignore?{gitignore:m.gitignore}:{}}}}catch(d){return d instanceof y?((t.err??t.out)(`error: ${e}: ${d.message}`),{code:1}):((t.err??t.out)(`error: ${e}: ${$e(d instanceof Error?d.message:String(d),"issue","Linear")}`),{code:1})}}async function An(e,n,t,r,i){let o=Z(e);if(o===null)return(t.err??t.out)(`error: ${e}: unsupported remote URL \u2014 expected a Linear document URL (https://linear.app/<workspace>/document/<slug>)`),{code:1};let u=await Lt(o,n,i);if(!u.ok)return(t.err??t.out)(`error: ${e}: ${u.failure.message}`),{code:1};let{bytes:l,title:s,uuid:c,site:a,sourceId:f,warnings:p,lis:h,lisDeps:g}=u;try{let d=Ce(r,"linear-doc",["document","uuid"],f,c,"document",a);if(d!==null)return(t.err??t.out)(`error: ${e}: ${d.message}`),{code:1};let m=await U({store:r,bytes:l,media:le,sourceId:f,label:e,confirmSameSource:t.isTTY?E=>t.confirm(`identical content already ingested as ${E} \u2014 treat as the same source?`):void 0,converters:{linearDoc:Ae({fetchAttachment:E=>h.linearAttachment(E,g)})}});t.out(B(t.isTTY,m,s));for(let E of p)t.out(`warning: ${E}`);for(let E of m.warnings??[])t.out(`warning: ${E}`);if(m.composite){let E=m.composite.delivered+m.composite.omitted;t.out(`${m.source_id}: linear document, ${E} images, ${m.composite.delivered} delivered (${m.composite.omitted} omitted)`)}return{code:0,result:{status:m.status,source_id:m.source_id,source_cid:m.cid,...m.gitignore?{gitignore:m.gitignore}:{}}}}catch(d){return d instanceof y?((t.err??t.out)(`error: ${e}: ${d.message}`),{code:1}):((t.err??t.out)(`error: ${e}: ${$e(d instanceof Error?d.message:String(d),"document","Linear")}`),{code:1})}}async function Sn(e,n,t){let r=X(e);if(r===null)return{ok:!1,failure:{code:"UNSUPPORTED_URL",message:"unsupported remote URL \u2014 expected a Linear issue URL (https://linear.app/<workspace>/issue/KEY-123)"}};if(n!==void 0&&!D(n))return{ok:!1,failure:{code:"BAD_SOURCE_ID",message:j(n)}};let i=await wt(r,n,t);return i.ok?{ok:!0,fetched:{provider:"linear",sourceId:i.sourceId,bytes:i.bytes,media:ue,label:e,display:i.key,origin:{kind:"linear",url:e},identity:{site:i.site,uuid:i.uuid},warnings:i.warnings}}:i}async function Rn(e,n,t){let r=Z(e);if(r===null)return{ok:!1,failure:{code:"UNSUPPORTED_URL",message:"unsupported remote URL \u2014 expected a Linear document URL (https://linear.app/<workspace>/document/<slug>)"}};if(n!==void 0&&!D(n))return{ok:!1,failure:{code:"BAD_SOURCE_ID",message:j(n)}};let i=await Lt(r,n,t);return i.ok?{ok:!0,fetched:{provider:"linear-doc",sourceId:i.sourceId,bytes:i.bytes,media:le,label:e,display:i.title,origin:{kind:"linear-doc",url:e},identity:{site:i.site,uuid:i.uuid},warnings:i.warnings}}:i}function It(e){return async(n,t,r)=>{let i=e==="linear",o=Ce(t,e,i?["issue","uuid"]:["document","uuid"],n.sourceId,n.identity.uuid??"",i?"issue":"document",n.identity.site??"");if(o!==null)return{ok:!1,failure:o};let u=r.linear??Oe,s={auth:await(r.authEnv??(async()=>(await import("./auth-7Z54TMQQ.js")).resolveLisAuthEnv({credentials:r.credentials})))(),env:process.env},c=a=>u.linearAttachment(a,s);return i?{ok:!0,media:ue,label:n.label,converters:{linear:ve({fetchAttachment:c})}}:{ok:!0,media:le,label:n.label,converters:{linearDoc:Ae({fetchAttachment:c})}}}}function $e(e,n,t){let r=e.match(/too large — ([\d.]+ [KM]B), the limit for .+ is ([\d.]+ [KM]B) \[FILE_TOO_LARGE\]/);return r?`the ${n}'s content is too large to ingest (${r[1]}; the limit is ${r[2]}) \u2014 trim the ${n} in ${t} and retry`:e.startsWith("PROJECTION_TOO_LARGE:")?`the ${n}'s text is too large to ingest \u2014 trim the ${n} in ${t} and retry`:e}var vt={name:"linear",hint:"Linear issue URLs (https://linear.app/<workspace>/issue/KEY-123)",match:e=>X(e)!==null,ingest:vn,sourceIdFor:ht,fetch:Sn,prepare:It("linear")},At={name:"linear-doc",hint:"Linear document URLs (https://linear.app/<workspace>/document/<slug>)",match:e=>Z(e)!==null,ingest:An,sourceIdFor:yt,fetch:Rn,prepare:It("linear-doc")};function Et(e){let n=Re(e);if(n===null){let t=ke(e);return t!==null?{code:"LINEAR_LINK_MALFORMED",message:`this Linear ${t.section} link is incomplete or malformed \u2014 use the full form (https://linear.app/${t.workspace}/issue/KEY-123 or https://linear.app/${t.workspace}/document/<slug>-<id>)`}:{code:"UNSUPPORTED_URL",message:"unsupported remote URL \u2014 expected a Linear workspace page"}}return{code:"LINEAR_PAGE",message:`this Linear page can't be ingested \u2014 only issue and document URLs are supported; ingest the project's issues or documents individually (https://linear.app/${n.workspace}/issue/KEY-123)`}}var St={name:"linear-page",hint:"Linear issue or document URLs (other linear.app pages are not ingestable)",match:e=>Re(e)!==null||ke(e)!==null,ingest:async(e,n,t)=>((t.err??t.out)(`error: ${e}: ${Et(e).message}`),{code:1}),sourceIdFor:()=>null,fetch:async e=>({ok:!1,failure:Et(e)})};var kn=new Set(["invalid_url","target_disallowed","page_not_found","page_access_blocked","page_paywalled","unsupported_content_type","page_too_large","page_timeout","scrape_unavailable","scrape_rate_limited","internal_error","credit_denied"]);async function Ne(e,n){let t=n.env??process.env,r=n.fetchImpl??fetch,i=xe(t),o={"Content-Type":"application/json"},u=await n.authEnv(),l=u.TESTMUAI_BASIC_AUTH??t.TESTMUAI_BASIC_AUTH,s=u.TESTMUAI_API_KEY??t.TESTMUAI_API_KEY;l?o.Authorization=`Basic ${l}`:s&&(o.Authorization=`Bearer ${s}`);let c;try{c=await r(`${i}/assurance/web/scrape`,{method:"POST",headers:o,body:JSON.stringify({url:e}),signal:AbortSignal.timeout(n.timeoutMs??55e3)})}catch{return{ok:!1,kind:"transport_unreachable"}}if(c.status===401)return{ok:!1,kind:"auth_rejected"};let a;try{a=await c.json()}catch{return{ok:!1,kind:c.status===404?"route_missing":"malformed_response"}}if(c.ok){let p=a.page;return p===void 0||typeof p.markdown!="string"||p.markdown===""||typeof p.final_url!="string"||p.final_url===""||typeof p.projection?.kind!="string"||typeof p.projection?.version!="string"?{ok:!1,kind:"malformed_response"}:{ok:!0,page:p}}let f=a.code;return typeof f=="string"&&kn.has(f)?{ok:!1,kind:f}:c.status===404?{ok:!1,kind:"route_missing"}:c.status===403?{ok:!1,kind:"auth_rejected"}:{ok:!1,kind:"malformed_response"}}var Pe="kane.source.web/1";function Te(e,n,t){if(t==="")throw new Error("cannot build a web source from an empty page projection");if(n.kind===""||n.version==="")throw new Error("cannot build a stable identity without a server-reported projection kind/version");let r={schema:Pe,url:e,projection:{kind:n.kind,version:n.version},content:{markdown:t}};return{bytes:Buffer.from(JSON.stringify(r),"utf8"),envelope:r}}var On=new Set(["markdown"]);function De(){return async e=>{let n;try{n=JSON.parse(e.toString("utf8"))}catch{throw new Error("this web source's stored envelope is not readable \u2014 re-ingest the page")}if(n.schema!==Pe)throw new Error(`unknown web envelope schema '${String(n.schema)}' \u2014 re-ingest the page with this CLI version`);if(!On.has(n.projection?.kind??""))throw new Error(v().text("note.web_projection_unknown",{kind:String(n.projection?.kind)}));if(typeof n.content?.markdown!="string"||n.content.markdown==="")throw new Error("this web source's stored envelope carries no content \u2014 re-ingest the page");return{projection:n.content.markdown,inventory:[],blobs:new Map,delivered:[],converter:{name:"web-convert",version:"1",policy:"markdown-passthrough"}}}}import{createHash as Cn}from"crypto";function Rt(e){return ie(e)!==null}function ie(e){if(!/^https?:\/\//i.test(e))return null;let n;try{n=new URL(e)}catch{return null}return n.hostname===""?null:(n.hash="",n.username="",n.password="",n.toString())}function Ee(e){let n=ie(e);if(n===null)return null;let t=new URL(n),r=(t.hostname+t.pathname).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40).replace(/-+$/,""),i=Cn("sha256").update(n,"utf8").digest("hex").slice(0,8);return`${r||"page"}-${i}`}function kt(e,n){let t=F(e),r=t.heads.get(n);if(r==null)return null;let i=t.getNode(r)?.content?.blob;if(typeof i!="string")return null;let o=e.getBlob(i);if(o===null)return null;try{let u=JSON.parse(o.toString("utf8"));return u.schema!=="kane.source.web/1"?null:typeof u.url=="string"&&u.url.length>0?u.url:null}catch{return null}}function oe(e){switch(e){case"invalid_url":return"this is not a valid public HTTP or HTTPS page URL \u2014 check the address and try again";case"target_disallowed":return"that address cannot be fetched because it does not point to an allowed public web page";case"page_not_found":return"the page could not be found \u2014 check that the URL is correct and that the page still exists";case"page_access_blocked":return"the page refused automated access, so its contents could not be ingested \u2014 use a publicly accessible version of the page";case"page_paywalled":return"the page is behind a paywall or sign-in screen, so its full contents could not be ingested \u2014 use a publicly accessible copy";case"unsupported_content_type":return"the URL does not point to an HTML web page \u2014 download the document and ingest the supported file instead";case"page_too_large":return"the page contains too much text to ingest as a single source \u2014 use a narrower page or trim the content first";case"page_timeout":return"the page took too long to load \u2014 try again later";case"scrape_unavailable":case"scrape_rate_limited":case"internal_error":return"the page ingest service is temporarily unavailable \u2014 try again later";case"credit_denied":return"the page could not be ingested \u2014 your organization is out of credits";case"auth_rejected":return v().text("note.web_login",{});case"route_missing":return"ingesting web pages is not available in your environment yet \u2014 nothing is wrong with the URL; try again later";case"transport_unreachable":return"the page ingest service could not be reached \u2014 check your connection and try again";case"malformed_response":return"the page ingest service returned a response that could not be read safely \u2014 try again later"}}function Ot(e){let n=e.match(/too large — ([\d.]+ [KM]B), the limit for .+ is ([\d.]+ [KM]B) \[FILE_TOO_LARGE\]/);return n?`the page contains too much text to ingest as a single source (${n[1]}; the limit is ${n[2]}) \u2014 use a narrower page or trim the content first`:e.startsWith("PROJECTION_TOO_LARGE:")?"the page contains too much text to ingest as a single source \u2014 use a narrower page or trim the content first":e}async function $n(e,n,t,r,i){let o=ie(e);if(o===null)return(t.err??t.out)(`error: ${e}: ${oe("invalid_url")}`),{code:1};let u=Ee(e),l=n??u;if(l===null)return(t.err??t.out)(`error: ${e}: ${oe("invalid_url")}`),{code:1};try{N(l)}catch(h){return(t.err??t.out)(`error: ${e}: ${h instanceof Error?h.message:String(h)}`),{code:1}}let s=x(r,l,"web");if(s!==null)return(t.err??t.out)(`error: ${e}: ${s}`),{code:1};let c=kt(r,l);if(c!==null&&c!==o){if(!t.isTTY)return(t.err??t.out)(`error: ${e}: ${v().text("note.web_url_changed",{source_id:l,previous:c})}`),{code:1};if(!await t.confirm(`source '${l}' was ingested from ${c} \u2014 treat ${o} as its new version (replaces the current version; items built on it go stale)?`))return t.out(v().text("note.web_id_taken",{url:e})),{code:1}}let a=i.web?.scrape??Ne,f=i.authEnv??(async()=>(await import("./spawner-C7NLLM4F.js")).resolveAgentAuthEnv(i.credentials)),p=await a(o,{authEnv:f});if(!p.ok)return(t.err??t.out)(`error: ${e}: ${oe(p.kind)}`),{code:1};try{let{bytes:h}=Te(o,p.page.projection,p.page.markdown),g=await U({store:r,bytes:h,media:ce,sourceId:l,label:o,confirmSameSource:t.isTTY?m=>t.confirm(`identical content already ingested as ${m} \u2014 treat as the same source?`):void 0,converters:{web:De()}}),d=new URL(o).hostname+new URL(o).pathname;t.out(B(t.isTTY,g,d));for(let m of g.warnings??[])t.out(`warning: ${m}`);return t.isTTY&&p.page.title&&t.out(` title: ${p.page.title}`),{code:0,result:{status:g.status,source_id:g.source_id,source_cid:g.cid,...g.gitignore?{gitignore:g.gitignore}:{}}}}catch(h){return(t.err??t.out)(`error: ${e}: ${Ot(h instanceof Error?h.message:String(h))}`),{code:1}}}async function Nn(e,n,t){let r=ie(e),i=r===null?null:n??Ee(e);if(r===null||i===null)return{ok:!1,failure:{code:"invalid_url",message:oe("invalid_url")}};if(!D(i))return{ok:!1,failure:{code:"BAD_SOURCE_ID",message:j(i)}};let o=t.web?.scrape??Ne,u=t.authEnv??(async()=>(await import("./spawner-C7NLLM4F.js")).resolveAgentAuthEnv(t.credentials)),l=await o(r,{authEnv:u});if(!l.ok)return{ok:!1,failure:{code:l.kind,message:oe(l.kind)}};try{let{bytes:s}=Te(r,l.page.projection,l.page.markdown),c=new URL(r);return{ok:!0,fetched:{provider:"web",sourceId:i,bytes:s,media:ce,label:r,display:c.hostname+c.pathname,origin:{kind:"web",url:r},identity:{url:r},warnings:[]}}}catch(s){return{ok:!1,failure:{code:"FETCH_FAILED",message:Ot(s instanceof Error?s.message:String(s))}}}}async function Pn(e,n){let t=x(n,e.sourceId,"web");if(t!==null)return{ok:!1,failure:{code:"KIND_MISMATCH",message:t,facts:{id:e.sourceId,heldKind:J(n,e.sourceId)??"",freeId:$(n,e.sourceId)}}};let r=kt(n,e.sourceId);return r!==null&&r!==e.identity.url?{ok:!1,failure:{code:"WEB_URL_CHANGED",message:v().text("note.web_url_changed",{source_id:e.sourceId,previous:r}),facts:{id:e.sourceId,previous:r,freeId:$(n,e.sourceId)}}}:{ok:!0,media:ce,label:e.label,converters:{web:De()}}}var Ct={name:"web",hint:"any public web page URL (https://\u2026)",match:Rt,ingest:$n,sourceIdFor:Ee,fetch:Nn,prepare:Pn};function B(e,n,t){return e?n.status==="created"?`landed ${n.source_id} (${t}) \u2014 new source`:n.status==="versioned"?`landed ${n.source_id} (${t}) \u2014 new version; dependents go stale`:`${n.source_id} unchanged \u2014 already landed`:`${n.status} ${n.source_id} source ${n.cid} blob ${n.blob}`}var $t=[Ye,nt,vt,At,St,Ct];function wi(e){return/^https?:\/\/.+/i.test(e)}function Li(e){return $t.find(n=>n.match(e))??null}function j(e){try{return N(e),""}catch(n){return n instanceof Error?n.message:String(n)}}function Ii(e){return $t.find(n=>n.name===e)??null}export{ne as a,pe as b,re as c,X as d,Z as e,Re as f,ke as g,B as h,$t as i,wi as j,Li as k,j as l,Ii as m};
17
+ `,inventory:u.inventory,blobs:u.blobs,delivered:u.delivered,converter:{name:"linear-doc-convert",version:"1",policy:"v1"}}}}var bn=/^[A-Za-z][A-Za-z0-9]*-\d+$/,_n=/-([0-9a-f]{12})$/;function Se(e){if(!/^https?:\/\/.+/i.test(e))return null;let n;try{n=new URL(e)}catch{return null}return n.hostname.toLowerCase()!=="linear.app"?null:n.pathname.split("/").filter(Boolean)}function mt(e){let n=Se(e);return n===null||n.length<3?null:{workspace:n[0],segs:n}}function X(e){let n=mt(e);if(n===null||n.segs[1]!=="issue")return null;let t=n.segs[2];return bn.test(t)?{workspace:n.workspace,key:t}:null}function Z(e){let n=mt(e);if(n===null||n.segs[1]!=="document")return null;let t=n.segs[2].match(_n);return t===null?null:{workspace:n.workspace,slugId:t[1]}}var wn=new Set(["project","team","view","initiative","cycle","roadmap","inbox","triage","my-issues"]),gt=new Set(["docs","features","method","blog","customers","pricing","integrations","developers","changelog","about","careers","security","download","contact","now","switch","homepage"]);function Re(e){let n=Se(e);return n===null||n.length<2||!wn.has(n[1])||gt.has(n[0].toLowerCase())?null:{workspace:n[0],section:n[1]}}function ke(e){let n=Se(e);return n===null||n.length<2||n[1]!=="issue"&&n[1]!=="document"||gt.has(n[0].toLowerCase())||X(e)!==null||Z(e)!==null?null:{workspace:n[0],section:n[1]}}function ht(e){let n=X(e);return n?n.key.toLowerCase():null}function yt(e){let n=Z(e);return n?`doc-${n.slugId}`:null}var Oe={linearInfo:rt,linearIssue:it,linearComments:ot,linearDocument:st,linearAttachment:at};function bt(e,n){if(e)try{let t=new URL(e).pathname.split("/").filter(Boolean)[0];if(t)return`linear.app/${t.toLowerCase()}`}catch{}return`linear.app/${n.toLowerCase()}`}function Ln(e,n,t,r,i,o){let u=pe(e,r);if(u!==null&&typeof u.schema=="string"&&u.schema.startsWith(`kane.source.${n}/`)){let s=u;for(let c of t)s=s!==null&&typeof s=="object"?s[c]:void 0;if(typeof s=="string"&&s!==""&&s!==i)return v().text("note.key_recycled",{source_id:r,what:o})}let l=we(e,n,t,i);return l!==null&&l!==r?`this ${o} is already ingested as '${l}' (its key changed) \u2014 reconcile that source, or retire it to re-ingest under the new key`:null}function In(e,n,t,r){let i=pe(e,t);if(i===null||typeof i.schema!="string"||!i.schema.startsWith(`kane.source.${n}/`))return null;let o=i.site;return typeof o!="string"||o.length===0||o===r?null:v().text("note.site_moved",{source_id:t,previous:o,site:r})}function Ce(e,n,t,r,i,o,u){let l=Ln(e,n,t,r,i,o);if(l!==null){let a=we(e,n,t,i);return{code:"UUID_MOVED",message:l,facts:a!==null&&a!==r?{holder:a}:{id:r,freeId:$(e,r)}}}let s=x(e,r,n);if(s!==null)return{code:"KIND_MISMATCH",message:s,facts:{id:r,heldKind:J(e,r)??"",freeId:$(e,r)}};let c=In(e,n,r,u);return c!==null?{code:"SITE_MOVED",message:c,facts:{id:r,freeId:$(e,r)}}:null}var _t=(e,n)=>e instanceof y?{code:e.code,message:e.message}:{code:"FETCH_FAILED",message:$e(e instanceof Error?e.message:String(e),n,"Linear")};async function wt(e,n,t){let r=t.linear??Oe;try{let o={auth:await(t.authEnv??(async()=>(await import("./auth-WBIEHHDS.js")).resolveLisAuthEnv({credentials:t.credentials})))(),env:process.env},u=await r.linearInfo(o);if(!u.installed)return{ok:!1,failure:{code:"NO_CONNECTION",message:`no Linear connection for this account \u2014 create one at ${A} and retry`}};if(u.capabilities.issue===!1||u.capabilities.comments===!1)return{ok:!1,failure:{code:"NO_ISSUE_ACCESS",message:`the connection cannot read issues or their comments yet \u2014 resync it at ${A} and retry`}};let l=await r.linearIssue(e.key,o),s=await r.linearComments(e.key,o),c=bt(l.host,e.workspace),{bytes:a,envelope:f,warnings:p}=ut(l,s,c),h=n??e.key.toLowerCase();try{N(h)}catch(g){return{ok:!1,failure:{code:"BAD_SOURCE_ID",message:g instanceof Error?g.message:String(g)}}}return{ok:!0,bytes:a,key:f.issue.key,uuid:f.issue.uuid,site:c,sourceId:h,warnings:p,lis:r,lisDeps:o}}catch(i){return{ok:!1,failure:_t(i,"issue")}}}async function Lt(e,n,t){let r=t.linear??Oe;try{let o={auth:await(t.authEnv??(async()=>(await import("./auth-WBIEHHDS.js")).resolveLisAuthEnv({credentials:t.credentials})))(),env:process.env},u=await r.linearInfo(o);if(!u.installed)return{ok:!1,failure:{code:"NO_CONNECTION",message:`no Linear connection for this account \u2014 create one at ${A} and retry`}};if(u.capabilities.document===!1)return{ok:!1,failure:{code:"NO_DOCUMENT_ACCESS",message:`the connection cannot read documents yet \u2014 resync it at ${A} and retry`}};let l=await r.linearDocument(e.slugId,o),s=bt(l.url,e.workspace),{bytes:c,envelope:a,warnings:f}=lt(l,s,e.slugId),p=n??`doc-${e.slugId}`;try{N(p)}catch(h){return{ok:!1,failure:{code:"BAD_SOURCE_ID",message:h instanceof Error?h.message:String(h)}}}return{ok:!0,bytes:c,title:a.title||`document ${e.slugId}`,uuid:a.document.uuid,site:s,sourceId:p,warnings:f,lis:r,lisDeps:o}}catch(i){return{ok:!1,failure:_t(i,"document")}}}async function vn(e,n,t,r,i){let o=X(e);if(o===null)return(t.err??t.out)(`error: ${e}: unsupported remote URL \u2014 expected a Linear issue URL (https://linear.app/<workspace>/issue/KEY-123)`),{code:1};let u=await wt(o,n,i);if(!u.ok)return(t.err??t.out)(`error: ${e}: ${u.failure.message}`),{code:1};let{bytes:l,key:s,uuid:c,site:a,sourceId:f,warnings:p,lis:h,lisDeps:g}=u;try{let d=Ce(r,"linear",["issue","uuid"],f,c,"issue",a);if(d!==null)return(t.err??t.out)(`error: ${e}: ${d.message}`),{code:1};let m=await U({store:r,bytes:l,media:ue,sourceId:f,label:e,confirmSameSource:t.isTTY?E=>t.confirm(`identical content already ingested as ${E} \u2014 treat as the same source?`):void 0,converters:{linear:ve({fetchAttachment:E=>h.linearAttachment(E,g)})}});t.out(B(t.isTTY,m,s));for(let E of p)t.out(`warning: ${E}`);for(let E of m.warnings??[])t.out(`warning: ${E}`);if(m.composite){let E=m.composite.delivered+m.composite.omitted;t.out(`${m.source_id}: linear, ${E} images, ${m.composite.delivered} delivered (${m.composite.omitted} omitted)`)}return{code:0,result:{status:m.status,source_id:m.source_id,source_cid:m.cid,...m.gitignore?{gitignore:m.gitignore}:{}}}}catch(d){return d instanceof y?((t.err??t.out)(`error: ${e}: ${d.message}`),{code:1}):((t.err??t.out)(`error: ${e}: ${$e(d instanceof Error?d.message:String(d),"issue","Linear")}`),{code:1})}}async function An(e,n,t,r,i){let o=Z(e);if(o===null)return(t.err??t.out)(`error: ${e}: unsupported remote URL \u2014 expected a Linear document URL (https://linear.app/<workspace>/document/<slug>)`),{code:1};let u=await Lt(o,n,i);if(!u.ok)return(t.err??t.out)(`error: ${e}: ${u.failure.message}`),{code:1};let{bytes:l,title:s,uuid:c,site:a,sourceId:f,warnings:p,lis:h,lisDeps:g}=u;try{let d=Ce(r,"linear-doc",["document","uuid"],f,c,"document",a);if(d!==null)return(t.err??t.out)(`error: ${e}: ${d.message}`),{code:1};let m=await U({store:r,bytes:l,media:le,sourceId:f,label:e,confirmSameSource:t.isTTY?E=>t.confirm(`identical content already ingested as ${E} \u2014 treat as the same source?`):void 0,converters:{linearDoc:Ae({fetchAttachment:E=>h.linearAttachment(E,g)})}});t.out(B(t.isTTY,m,s));for(let E of p)t.out(`warning: ${E}`);for(let E of m.warnings??[])t.out(`warning: ${E}`);if(m.composite){let E=m.composite.delivered+m.composite.omitted;t.out(`${m.source_id}: linear document, ${E} images, ${m.composite.delivered} delivered (${m.composite.omitted} omitted)`)}return{code:0,result:{status:m.status,source_id:m.source_id,source_cid:m.cid,...m.gitignore?{gitignore:m.gitignore}:{}}}}catch(d){return d instanceof y?((t.err??t.out)(`error: ${e}: ${d.message}`),{code:1}):((t.err??t.out)(`error: ${e}: ${$e(d instanceof Error?d.message:String(d),"document","Linear")}`),{code:1})}}async function Sn(e,n,t){let r=X(e);if(r===null)return{ok:!1,failure:{code:"UNSUPPORTED_URL",message:"unsupported remote URL \u2014 expected a Linear issue URL (https://linear.app/<workspace>/issue/KEY-123)"}};if(n!==void 0&&!D(n))return{ok:!1,failure:{code:"BAD_SOURCE_ID",message:j(n)}};let i=await wt(r,n,t);return i.ok?{ok:!0,fetched:{provider:"linear",sourceId:i.sourceId,bytes:i.bytes,media:ue,label:e,display:i.key,origin:{kind:"linear",url:e},identity:{site:i.site,uuid:i.uuid},warnings:i.warnings}}:i}async function Rn(e,n,t){let r=Z(e);if(r===null)return{ok:!1,failure:{code:"UNSUPPORTED_URL",message:"unsupported remote URL \u2014 expected a Linear document URL (https://linear.app/<workspace>/document/<slug>)"}};if(n!==void 0&&!D(n))return{ok:!1,failure:{code:"BAD_SOURCE_ID",message:j(n)}};let i=await Lt(r,n,t);return i.ok?{ok:!0,fetched:{provider:"linear-doc",sourceId:i.sourceId,bytes:i.bytes,media:le,label:e,display:i.title,origin:{kind:"linear-doc",url:e},identity:{site:i.site,uuid:i.uuid},warnings:i.warnings}}:i}function It(e){return async(n,t,r)=>{let i=e==="linear",o=Ce(t,e,i?["issue","uuid"]:["document","uuid"],n.sourceId,n.identity.uuid??"",i?"issue":"document",n.identity.site??"");if(o!==null)return{ok:!1,failure:o};let u=r.linear??Oe,s={auth:await(r.authEnv??(async()=>(await import("./auth-WBIEHHDS.js")).resolveLisAuthEnv({credentials:r.credentials})))(),env:process.env},c=a=>u.linearAttachment(a,s);return i?{ok:!0,media:ue,label:n.label,converters:{linear:ve({fetchAttachment:c})}}:{ok:!0,media:le,label:n.label,converters:{linearDoc:Ae({fetchAttachment:c})}}}}function $e(e,n,t){let r=e.match(/too large — ([\d.]+ [KM]B), the limit for .+ is ([\d.]+ [KM]B) \[FILE_TOO_LARGE\]/);return r?`the ${n}'s content is too large to ingest (${r[1]}; the limit is ${r[2]}) \u2014 trim the ${n} in ${t} and retry`:e.startsWith("PROJECTION_TOO_LARGE:")?`the ${n}'s text is too large to ingest \u2014 trim the ${n} in ${t} and retry`:e}var vt={name:"linear",hint:"Linear issue URLs (https://linear.app/<workspace>/issue/KEY-123)",match:e=>X(e)!==null,ingest:vn,sourceIdFor:ht,fetch:Sn,prepare:It("linear")},At={name:"linear-doc",hint:"Linear document URLs (https://linear.app/<workspace>/document/<slug>)",match:e=>Z(e)!==null,ingest:An,sourceIdFor:yt,fetch:Rn,prepare:It("linear-doc")};function Et(e){let n=Re(e);if(n===null){let t=ke(e);return t!==null?{code:"LINEAR_LINK_MALFORMED",message:`this Linear ${t.section} link is incomplete or malformed \u2014 use the full form (https://linear.app/${t.workspace}/issue/KEY-123 or https://linear.app/${t.workspace}/document/<slug>-<id>)`}:{code:"UNSUPPORTED_URL",message:"unsupported remote URL \u2014 expected a Linear workspace page"}}return{code:"LINEAR_PAGE",message:`this Linear page can't be ingested \u2014 only issue and document URLs are supported; ingest the project's issues or documents individually (https://linear.app/${n.workspace}/issue/KEY-123)`}}var St={name:"linear-page",hint:"Linear issue or document URLs (other linear.app pages are not ingestable)",match:e=>Re(e)!==null||ke(e)!==null,ingest:async(e,n,t)=>((t.err??t.out)(`error: ${e}: ${Et(e).message}`),{code:1}),sourceIdFor:()=>null,fetch:async e=>({ok:!1,failure:Et(e)})};var kn=new Set(["invalid_url","target_disallowed","page_not_found","page_access_blocked","page_paywalled","unsupported_content_type","page_too_large","page_timeout","scrape_unavailable","scrape_rate_limited","internal_error","credit_denied"]);async function Ne(e,n){let t=n.env??process.env,r=n.fetchImpl??fetch,i=xe(t),o={"Content-Type":"application/json"},u=await n.authEnv(),l=u.TESTMUAI_BASIC_AUTH??t.TESTMUAI_BASIC_AUTH,s=u.TESTMUAI_API_KEY??t.TESTMUAI_API_KEY;l?o.Authorization=`Basic ${l}`:s&&(o.Authorization=`Bearer ${s}`);let c;try{c=await r(`${i}/assurance/web/scrape`,{method:"POST",headers:o,body:JSON.stringify({url:e}),signal:AbortSignal.timeout(n.timeoutMs??55e3)})}catch{return{ok:!1,kind:"transport_unreachable"}}if(c.status===401)return{ok:!1,kind:"auth_rejected"};let a;try{a=await c.json()}catch{return{ok:!1,kind:c.status===404?"route_missing":"malformed_response"}}if(c.ok){let p=a.page;return p===void 0||typeof p.markdown!="string"||p.markdown===""||typeof p.final_url!="string"||p.final_url===""||typeof p.projection?.kind!="string"||typeof p.projection?.version!="string"?{ok:!1,kind:"malformed_response"}:{ok:!0,page:p}}let f=a.code;return typeof f=="string"&&kn.has(f)?{ok:!1,kind:f}:c.status===404?{ok:!1,kind:"route_missing"}:c.status===403?{ok:!1,kind:"auth_rejected"}:{ok:!1,kind:"malformed_response"}}var Pe="kane.source.web/1";function Te(e,n,t){if(t==="")throw new Error("cannot build a web source from an empty page projection");if(n.kind===""||n.version==="")throw new Error("cannot build a stable identity without a server-reported projection kind/version");let r={schema:Pe,url:e,projection:{kind:n.kind,version:n.version},content:{markdown:t}};return{bytes:Buffer.from(JSON.stringify(r),"utf8"),envelope:r}}var On=new Set(["markdown"]);function De(){return async e=>{let n;try{n=JSON.parse(e.toString("utf8"))}catch{throw new Error("this web source's stored envelope is not readable \u2014 re-ingest the page")}if(n.schema!==Pe)throw new Error(`unknown web envelope schema '${String(n.schema)}' \u2014 re-ingest the page with this CLI version`);if(!On.has(n.projection?.kind??""))throw new Error(v().text("note.web_projection_unknown",{kind:String(n.projection?.kind)}));if(typeof n.content?.markdown!="string"||n.content.markdown==="")throw new Error("this web source's stored envelope carries no content \u2014 re-ingest the page");return{projection:n.content.markdown,inventory:[],blobs:new Map,delivered:[],converter:{name:"web-convert",version:"1",policy:"markdown-passthrough"}}}}import{createHash as Cn}from"crypto";function Rt(e){return ie(e)!==null}function ie(e){if(!/^https?:\/\//i.test(e))return null;let n;try{n=new URL(e)}catch{return null}return n.hostname===""?null:(n.hash="",n.username="",n.password="",n.toString())}function Ee(e){let n=ie(e);if(n===null)return null;let t=new URL(n),r=(t.hostname+t.pathname).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40).replace(/-+$/,""),i=Cn("sha256").update(n,"utf8").digest("hex").slice(0,8);return`${r||"page"}-${i}`}function kt(e,n){let t=F(e),r=t.heads.get(n);if(r==null)return null;let i=t.getNode(r)?.content?.blob;if(typeof i!="string")return null;let o=e.getBlob(i);if(o===null)return null;try{let u=JSON.parse(o.toString("utf8"));return u.schema!=="kane.source.web/1"?null:typeof u.url=="string"&&u.url.length>0?u.url:null}catch{return null}}function oe(e){switch(e){case"invalid_url":return"this is not a valid public HTTP or HTTPS page URL \u2014 check the address and try again";case"target_disallowed":return"that address cannot be fetched because it does not point to an allowed public web page";case"page_not_found":return"the page could not be found \u2014 check that the URL is correct and that the page still exists";case"page_access_blocked":return"the page refused automated access, so its contents could not be ingested \u2014 use a publicly accessible version of the page";case"page_paywalled":return"the page is behind a paywall or sign-in screen, so its full contents could not be ingested \u2014 use a publicly accessible copy";case"unsupported_content_type":return"the URL does not point to an HTML web page \u2014 download the document and ingest the supported file instead";case"page_too_large":return"the page contains too much text to ingest as a single source \u2014 use a narrower page or trim the content first";case"page_timeout":return"the page took too long to load \u2014 try again later";case"scrape_unavailable":case"scrape_rate_limited":case"internal_error":return"the page ingest service is temporarily unavailable \u2014 try again later";case"credit_denied":return"the page could not be ingested \u2014 your organization is out of credits";case"auth_rejected":return v().text("note.web_login",{});case"route_missing":return"ingesting web pages is not available in your environment yet \u2014 nothing is wrong with the URL; try again later";case"transport_unreachable":return"the page ingest service could not be reached \u2014 check your connection and try again";case"malformed_response":return"the page ingest service returned a response that could not be read safely \u2014 try again later"}}function Ot(e){let n=e.match(/too large — ([\d.]+ [KM]B), the limit for .+ is ([\d.]+ [KM]B) \[FILE_TOO_LARGE\]/);return n?`the page contains too much text to ingest as a single source (${n[1]}; the limit is ${n[2]}) \u2014 use a narrower page or trim the content first`:e.startsWith("PROJECTION_TOO_LARGE:")?"the page contains too much text to ingest as a single source \u2014 use a narrower page or trim the content first":e}async function $n(e,n,t,r,i){let o=ie(e);if(o===null)return(t.err??t.out)(`error: ${e}: ${oe("invalid_url")}`),{code:1};let u=Ee(e),l=n??u;if(l===null)return(t.err??t.out)(`error: ${e}: ${oe("invalid_url")}`),{code:1};try{N(l)}catch(h){return(t.err??t.out)(`error: ${e}: ${h instanceof Error?h.message:String(h)}`),{code:1}}let s=x(r,l,"web");if(s!==null)return(t.err??t.out)(`error: ${e}: ${s}`),{code:1};let c=kt(r,l);if(c!==null&&c!==o){if(!t.isTTY)return(t.err??t.out)(`error: ${e}: ${v().text("note.web_url_changed",{source_id:l,previous:c})}`),{code:1};if(!await t.confirm(`source '${l}' was ingested from ${c} \u2014 treat ${o} as its new version (replaces the current version; items built on it go stale)?`))return t.out(v().text("note.web_id_taken",{url:e})),{code:1}}let a=i.web?.scrape??Ne,f=i.authEnv??(async()=>(await import("./spawner-MQ4XEHIX.js")).resolveAgentAuthEnv(i.credentials)),p=await a(o,{authEnv:f});if(!p.ok)return(t.err??t.out)(`error: ${e}: ${oe(p.kind)}`),{code:1};try{let{bytes:h}=Te(o,p.page.projection,p.page.markdown),g=await U({store:r,bytes:h,media:ce,sourceId:l,label:o,confirmSameSource:t.isTTY?m=>t.confirm(`identical content already ingested as ${m} \u2014 treat as the same source?`):void 0,converters:{web:De()}}),d=new URL(o).hostname+new URL(o).pathname;t.out(B(t.isTTY,g,d));for(let m of g.warnings??[])t.out(`warning: ${m}`);return t.isTTY&&p.page.title&&t.out(` title: ${p.page.title}`),{code:0,result:{status:g.status,source_id:g.source_id,source_cid:g.cid,...g.gitignore?{gitignore:g.gitignore}:{}}}}catch(h){return(t.err??t.out)(`error: ${e}: ${Ot(h instanceof Error?h.message:String(h))}`),{code:1}}}async function Nn(e,n,t){let r=ie(e),i=r===null?null:n??Ee(e);if(r===null||i===null)return{ok:!1,failure:{code:"invalid_url",message:oe("invalid_url")}};if(!D(i))return{ok:!1,failure:{code:"BAD_SOURCE_ID",message:j(i)}};let o=t.web?.scrape??Ne,u=t.authEnv??(async()=>(await import("./spawner-MQ4XEHIX.js")).resolveAgentAuthEnv(t.credentials)),l=await o(r,{authEnv:u});if(!l.ok)return{ok:!1,failure:{code:l.kind,message:oe(l.kind)}};try{let{bytes:s}=Te(r,l.page.projection,l.page.markdown),c=new URL(r);return{ok:!0,fetched:{provider:"web",sourceId:i,bytes:s,media:ce,label:r,display:c.hostname+c.pathname,origin:{kind:"web",url:r},identity:{url:r},warnings:[]}}}catch(s){return{ok:!1,failure:{code:"FETCH_FAILED",message:Ot(s instanceof Error?s.message:String(s))}}}}async function Pn(e,n){let t=x(n,e.sourceId,"web");if(t!==null)return{ok:!1,failure:{code:"KIND_MISMATCH",message:t,facts:{id:e.sourceId,heldKind:J(n,e.sourceId)??"",freeId:$(n,e.sourceId)}}};let r=kt(n,e.sourceId);return r!==null&&r!==e.identity.url?{ok:!1,failure:{code:"WEB_URL_CHANGED",message:v().text("note.web_url_changed",{source_id:e.sourceId,previous:r}),facts:{id:e.sourceId,previous:r,freeId:$(n,e.sourceId)}}}:{ok:!0,media:ce,label:e.label,converters:{web:De()}}}var Ct={name:"web",hint:"any public web page URL (https://\u2026)",match:Rt,ingest:$n,sourceIdFor:Ee,fetch:Nn,prepare:Pn};function B(e,n,t){return e?n.status==="created"?`landed ${n.source_id} (${t}) \u2014 new source`:n.status==="versioned"?`landed ${n.source_id} (${t}) \u2014 new version; dependents go stale`:`${n.source_id} unchanged \u2014 already landed`:`${n.status} ${n.source_id} source ${n.cid} blob ${n.blob}`}var $t=[Ye,nt,vt,At,St,Ct];function wi(e){return/^https?:\/\/.+/i.test(e)}function Li(e){return $t.find(n=>n.match(e))??null}function j(e){try{return N(e),""}catch(n){return n instanceof Error?n.message:String(n)}}function Ii(e){return $t.find(n=>n.name===e)??null}export{ne as a,pe as b,re as c,X as d,Z as e,Re as f,ke as g,B as h,$t as i,wi as j,Li as k,j as l,Ii as m};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{Ea as L,Ua as U}from"./chunk-UEE3RZN4.js";import{a as E}from"./chunk-7DFBOVUB.js";var x="ckpt/1";var B="checkpoints",m="base.json",y=t=>`delta-${t}.json`,w=t=>`full-${t}.json`,re=["turn","ask","final"],se=["extract","design","walk"];function d(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function D(t){return Array.isArray(t)&&t.every(r=>typeof r=="string")}function K(t){let r=[],e=(n,i)=>{n||r.push(i)};if(!d(t))return{ok:!1,errors:["record: not an object"]};e(t.schema===x,`schema: expected "${x}"`);let s=t.kind;if(s==="base")e(typeof t.sid=="string"&&t.sid.length>0,"base.sid: non-empty string"),e(typeof t.verb=="string"&&se.includes(t.verb),"base.verb: extract|design|walk"),e(typeof t.mode=="string","base.mode: string"),e(typeof t.created_at=="string","base.created_at: string"),e(d(t.run_config),"base.run_config: object"),d(t.run_config)&&e(!("resume"in t.run_config),"base.run_config: must not carry `resume`"),e(typeof t.conv_source=="string",'base.conv_source: string ("" when absent)'),e(typeof t.store_watermark=="string"||t.store_watermark===null,"base.store_watermark: string | null (null = genesis)");else if(s==="delta"||s==="full"){e(typeof t.sid=="string"&&t.sid.length>0,"delta.sid: non-empty string"),e(Number.isInteger(t.seq)&&t.seq>=1,"delta.seq: integer \u2265 1"),e(Number.isInteger(t.turn_id),"delta.turn_id: integer"),e(typeof t.at=="string"&&re.includes(t.at),"delta.at: turn|ask|final"),e(typeof t.ts=="string","delta.ts: string");let n=t.agent;if(d(n)){e(Number.isInteger(n.agent_state_schema),"agent.agent_state_schema: integer"),e(Array.isArray(n.delta_items),"agent.delta_items: array"),e(d(n.binding),"agent.binding: object");let o=n.usage_total;e(d(o)&&typeof o.input_tokens=="number"&&typeof o.output_tokens=="number"&&typeof o.credits=="number","agent.usage_total: {input_tokens, output_tokens, credits} numbers"),n.base_fingerprint!==void 0&&e(typeof n.base_fingerprint=="string","agent.base_fingerprint: string when present"),s==="full"&&e(typeof n.base_fingerprint=="string","full: agent.base_fingerprint required")}else r.push("delta.agent: object");let i=t.kane;if(d(i)){e(D(i.applied_events),"kane.applied_events: string[]"),e(D(i.held_receipts),"kane.held_receipts: string[]");let o=i.pending;e(d(o)&&Array.isArray(o.questions)&&Array.isArray(o.proposals),"kane.pending: {questions[], proposals[]}"),e(Array.isArray(i.parent_asks),"kane.parent_asks: array"),e(d(i.read_basis),"kane.read_basis: object");let p=i.corpus_cursor;if(e(d(p)&&D(p.remaining),"kane.corpus_cursor: {remaining: string[]}"),e(typeof i.store_watermark=="string"||i.store_watermark===null,"kane.store_watermark: string | null (null = genesis)"),i.awaits!==void 0){let a=i.awaits;e(d(i.awaits)&&typeof a.call=="string"&&(typeof a.event_id=="string"||typeof a.event_prefix=="string"),"kane.awaits: {call, event_id | event_prefix}")}i.ingest_registry!==void 0&&e(Array.isArray(i.ingest_registry)&&i.ingest_registry.every(a=>d(a)&&typeof a.ref=="string"&&typeof a.entered_at=="string"),"kane.ingest_registry: [{ref, entered_at, consumed?}]"),i.sent_unread!==void 0&&e(D(i.sent_unread),"kane.sent_unread: string[]"),i.ingest_schedule!==void 0&&e(Array.isArray(i.ingest_schedule)&&i.ingest_schedule.every(a=>d(a)&&typeof a.source_id=="string"&&typeof a.cid=="string"&&["pending","done","skipped"].includes(String(a.status))),"kane.ingest_schedule: [{source_id, cid, status}]")}else r.push("delta.kane: object")}else r.push('kind: expected "base" | "delta" | "full"');return{ok:r.length===0,errors:r}}import{readFileSync as ke}from"fs";import{join as _e}from"path";import{closeSync as N,linkSync as ie,mkdirSync as G,openSync as I,readFileSync as oe,readdirSync as Y,renameSync as ae,rmSync as F,statSync as ce,writeFileSync as M}from"fs";import{join as j}from"path";function pe(t,r){let e=j(t,"sessions",r,B),s=n=>j(e,n);return{read:n=>{try{return oe(s(n),"utf8")}catch(i){if(i.code==="ENOENT")return null;throw i}},list:()=>{try{return Y(e)}catch{return[]}},write:(n,i)=>{G(e,{recursive:!0}),le(s(n),i,e)},writeIfAbsent:(n,i)=>(G(e,{recursive:!0}),de(s(n),i,e)),remove:n=>F(s(n),{force:!0}),bytes:()=>fe(e)}}function le(t,r,e){let s=`${t}.tmp-${process.pid}`,n=I(s,"w");try{M(n,r,{mode:384}),E(n)}finally{N(n)}ae(s,t);try{let i=I(e,"r");E(i),N(i)}catch{}}var ue=new Set(["EPERM","ENOTSUP","EXDEV"]);function de(t,r,e){let s=`${t}.tmp-${process.pid}`,n=I(s,"w");try{M(n,r,{mode:384}),E(n)}finally{N(n)}try{ie(s,t)}catch(i){let o=i.code??"";if(o==="EEXIST")return!1;if(!ue.has(o))throw i;if(!ge(t,r))return!1}finally{F(s,{force:!0})}try{let i=I(e,"r");E(i),N(i)}catch{}return!0}function ge(t,r){let e;try{e=I(t,"wx")}catch(n){if(n.code==="EEXIST")return!1;throw n}let s=!1;try{M(e,r),E(e),s=!0}finally{N(e),s||F(t,{force:!0})}return!0}function fe(t){let r=0;try{for(let e of Y(t))try{r+=ce(j(t,e)).size}catch{}}catch{return 0}return r}var me=3,$e=600*1e3,h=class extends Error{constructor(e,s){super(`${e}: ${s}`);this.code=e}},S=class extends Error{constructor(r){super(`CHECKPOINT_WRITE: ${r}`)}},V=class extends S{},he=(t,r)=>_e(t,"sessions",r,"state.json"),Ce=new Set,J=new Set;function W(t,r,e){for(let s of Ce)try{s(t,r,e)}catch{}}var be=new Set;function De(t,r=new Date){for(let e of be)try{e(t,r)}catch{}}function He(t,r){let e=JSON.stringify(r)+`
2
+ import{Ea as L,Ua as U}from"./chunk-PI7OXS62.js";import{a as E}from"./chunk-YJAQZMJT.js";var x="ckpt/1";var B="checkpoints",m="base.json",y=t=>`delta-${t}.json`,w=t=>`full-${t}.json`,re=["turn","ask","final"],se=["extract","design","walk"];function d(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function D(t){return Array.isArray(t)&&t.every(r=>typeof r=="string")}function K(t){let r=[],e=(n,i)=>{n||r.push(i)};if(!d(t))return{ok:!1,errors:["record: not an object"]};e(t.schema===x,`schema: expected "${x}"`);let s=t.kind;if(s==="base")e(typeof t.sid=="string"&&t.sid.length>0,"base.sid: non-empty string"),e(typeof t.verb=="string"&&se.includes(t.verb),"base.verb: extract|design|walk"),e(typeof t.mode=="string","base.mode: string"),e(typeof t.created_at=="string","base.created_at: string"),e(d(t.run_config),"base.run_config: object"),d(t.run_config)&&e(!("resume"in t.run_config),"base.run_config: must not carry `resume`"),e(typeof t.conv_source=="string",'base.conv_source: string ("" when absent)'),e(typeof t.store_watermark=="string"||t.store_watermark===null,"base.store_watermark: string | null (null = genesis)");else if(s==="delta"||s==="full"){e(typeof t.sid=="string"&&t.sid.length>0,"delta.sid: non-empty string"),e(Number.isInteger(t.seq)&&t.seq>=1,"delta.seq: integer \u2265 1"),e(Number.isInteger(t.turn_id),"delta.turn_id: integer"),e(typeof t.at=="string"&&re.includes(t.at),"delta.at: turn|ask|final"),e(typeof t.ts=="string","delta.ts: string");let n=t.agent;if(d(n)){e(Number.isInteger(n.agent_state_schema),"agent.agent_state_schema: integer"),e(Array.isArray(n.delta_items),"agent.delta_items: array"),e(d(n.binding),"agent.binding: object");let o=n.usage_total;e(d(o)&&typeof o.input_tokens=="number"&&typeof o.output_tokens=="number"&&typeof o.credits=="number","agent.usage_total: {input_tokens, output_tokens, credits} numbers"),n.base_fingerprint!==void 0&&e(typeof n.base_fingerprint=="string","agent.base_fingerprint: string when present"),s==="full"&&e(typeof n.base_fingerprint=="string","full: agent.base_fingerprint required")}else r.push("delta.agent: object");let i=t.kane;if(d(i)){e(D(i.applied_events),"kane.applied_events: string[]"),e(D(i.held_receipts),"kane.held_receipts: string[]");let o=i.pending;e(d(o)&&Array.isArray(o.questions)&&Array.isArray(o.proposals),"kane.pending: {questions[], proposals[]}"),e(Array.isArray(i.parent_asks),"kane.parent_asks: array"),e(d(i.read_basis),"kane.read_basis: object");let p=i.corpus_cursor;if(e(d(p)&&D(p.remaining),"kane.corpus_cursor: {remaining: string[]}"),e(typeof i.store_watermark=="string"||i.store_watermark===null,"kane.store_watermark: string | null (null = genesis)"),i.awaits!==void 0){let a=i.awaits;e(d(i.awaits)&&typeof a.call=="string"&&(typeof a.event_id=="string"||typeof a.event_prefix=="string"),"kane.awaits: {call, event_id | event_prefix}")}i.ingest_registry!==void 0&&e(Array.isArray(i.ingest_registry)&&i.ingest_registry.every(a=>d(a)&&typeof a.ref=="string"&&typeof a.entered_at=="string"),"kane.ingest_registry: [{ref, entered_at, consumed?}]"),i.sent_unread!==void 0&&e(D(i.sent_unread),"kane.sent_unread: string[]"),i.ingest_schedule!==void 0&&e(Array.isArray(i.ingest_schedule)&&i.ingest_schedule.every(a=>d(a)&&typeof a.source_id=="string"&&typeof a.cid=="string"&&["pending","done","skipped"].includes(String(a.status))),"kane.ingest_schedule: [{source_id, cid, status}]")}else r.push("delta.kane: object")}else r.push('kind: expected "base" | "delta" | "full"');return{ok:r.length===0,errors:r}}import{readFileSync as ke}from"fs";import{join as _e}from"path";import{closeSync as N,linkSync as ie,mkdirSync as G,openSync as I,readFileSync as oe,readdirSync as Y,renameSync as ae,rmSync as F,statSync as ce,writeFileSync as M}from"fs";import{join as j}from"path";function pe(t,r){let e=j(t,"sessions",r,B),s=n=>j(e,n);return{read:n=>{try{return oe(s(n),"utf8")}catch(i){if(i.code==="ENOENT")return null;throw i}},list:()=>{try{return Y(e)}catch{return[]}},write:(n,i)=>{G(e,{recursive:!0}),le(s(n),i,e)},writeIfAbsent:(n,i)=>(G(e,{recursive:!0}),de(s(n),i,e)),remove:n=>F(s(n),{force:!0}),bytes:()=>fe(e)}}function le(t,r,e){let s=`${t}.tmp-${process.pid}`,n=I(s,"w");try{M(n,r,{mode:384}),E(n)}finally{N(n)}ae(s,t);try{let i=I(e,"r");E(i),N(i)}catch{}}var ue=new Set(["EPERM","ENOTSUP","EXDEV"]);function de(t,r,e){let s=`${t}.tmp-${process.pid}`,n=I(s,"w");try{M(n,r,{mode:384}),E(n)}finally{N(n)}try{ie(s,t)}catch(i){let o=i.code??"";if(o==="EEXIST")return!1;if(!ue.has(o))throw i;if(!ge(t,r))return!1}finally{F(s,{force:!0})}try{let i=I(e,"r");E(i),N(i)}catch{}return!0}function ge(t,r){let e;try{e=I(t,"wx")}catch(n){if(n.code==="EEXIST")return!1;throw n}let s=!1;try{M(e,r),E(e),s=!0}finally{N(e),s||F(t,{force:!0})}return!0}function fe(t){let r=0;try{for(let e of Y(t))try{r+=ce(j(t,e)).size}catch{}}catch{return 0}return r}var me=3,$e=600*1e3,h=class extends Error{constructor(e,s){super(`${e}: ${s}`);this.code=e}},S=class extends Error{constructor(r){super(`CHECKPOINT_WRITE: ${r}`)}},V=class extends S{},he=(t,r)=>_e(t,"sessions",r,"state.json"),Ce=new Set,J=new Set;function W(t,r,e){for(let s of Ce)try{s(t,r,e)}catch{}}var be=new Set;function De(t,r=new Date){for(let e of be)try{e(t,r)}catch{}}function He(t,r){let e=JSON.stringify(r)+`
3
3
  `;t.writeIfAbsent(m,e)||ye(t.read(m))||(t.remove(m),t.writeIfAbsent(m,e))}function ye(t){if(t===null)return!1;try{return JSON.parse(t),!0}catch{return!1}}function Z(t,r){let e;try{e=JSON.parse(r)}catch(n){throw new h("CHECKPOINT_CORRUPT",`${t}: ${n.message}`)}let s=K(e);if(!s.ok)throw new h("CHECKPOINT_CORRUPT",`${t}: ${s.errors.join("; ")}`);return e}function X(t,r){let e=t.read(r);if(e===null)throw new h("CHECKPOINT_MISSING",`${r} is not in the chain`);return Z(r,e)}function ee(t){let r=[],e=[];for(let s of t.list()){let n=/^delta-(\d+)\.json$/.exec(s);n&&r.push(Number(n[1]));let i=/^full-(\d+)\.json$/.exec(s);i&&e.push(Number(i[1]))}return r.sort((s,n)=>s-n),e.sort((s,n)=>s-n),{deltas:r,fulls:e}}function Be(t,r){try{return JSON.parse(ke(he(t,r),"utf8")).checkpoint??null}catch{return null}}function te(t,r,e){let s=[],n,i=0;if(e.full_seq!==null){let a=X(t,w(e.full_seq));s.push(a),n=a.agent.base_fingerprint,i=e.full_seq}let o;for(let a=i+1;a<=e.seq;a++)try{let u=X(t,y(a));s.push(u),!n&&u.agent.base_fingerprint&&(n=u.agent.base_fingerprint)}catch(u){if(u instanceof h&&u.code==="CHECKPOINT_CORRUPT"){o={resumableAt:a-1,turnsLost:e.seq-(a-1)};break}throw u}if(s.length===0)throw new h("CHECKPOINT_CORRUPT",`${r}: pointer names seq ${e.seq} but no chain records exist`);return{items:s.flatMap(a=>a.agent.delta_items),last:s[s.length-1],base_fingerprint:n,fallback:o}}function Ke(t,r,e,s,n){let i=performance.now(),o=r.state.sid,p=r.state.checkpoint;if(p){if(e.seq<p.seq)throw new S(`seq regression: got ${e.seq}, pointer at ${p.seq} (${o})`);if(e.seq===p.seq){if(e.turn_id===p.turn_id&&e.at===p.at)return p;throw new S(`seq regression: seq ${e.seq} re-used with different metadata (turn ${e.turn_id}/${p.turn_id}, at ${e.at}/${p.at}) (${o})`)}}let a=(n?.now??(()=>new Date))(),u=a.toISOString(),l={schema:x,kind:"delta",sid:o,seq:e.seq,turn_id:e.turn_id,at:e.at,ts:u,agent:{agent_state_schema:e.agent_state_schema,delta_items:e.delta_items,binding:e.binding,usage_total:e.usage_total,...e.base_fingerprint!==void 0?{base_fingerprint:e.base_fingerprint}:{}},kane:s},A=Math.max(1,n?.retries??me),g=JSON.stringify(l)+`
4
4
  `,C=!1;Buffer.byteLength(g)>524288&&!J.has(o)&&(J.add(o),C=!0,n?.onSoftCap?.("note: this session's checkpoints are getting large \u2014 long pasted inputs are kept verbatim; consider ingesting big documents as sources instead"));let v=!1,q;for(let f=0;f<A&&!v;f++)try{t.write(y(e.seq),g),v=!0}catch(k){q=k}if(!v)throw new S(`delta-${e.seq} write failed after ${A} attempts: ${q?.message??"unknown"} (${o})`);let _=p?.full_seq??null,P=t.bytes()>67108864;if(e.seq%25===0||P){let f=[],k=e.base_fingerprint;if(p){let R=te(t,o,p);f=R.items,k=k??R.base_fingerprint}if(f=[...f,...e.delta_items],!k)throw new S(`compaction at seq ${e.seq}: no base_fingerprint anywhere in the chain (${o})`);let c={...l,kind:"full",agent:{...l.agent,delta_items:f,base_fingerprint:k}};t.write(w(e.seq),JSON.stringify(c)+`
5
5
  `),_=e.seq}let b={seq:e.seq,turn_id:e.turn_id,at:e.at,ts:u,full_seq:_};if(r.save({checkpoint:b}),_===e.seq){let{deltas:f,fulls:k}=ee(t);for(let c of f)c<=_&&t.remove(y(c));for(let c of k)c<_&&t.remove(w(c))}let T=t.bytes();if(P&&T>67108864)throw W(o,b,a),new V(`session ${o} checkpoint dir is ${Math.round(T/(1024*1024))}MB (cap ${Math.round(67108864/(1024*1024))}MB) even after compaction \u2014 pausing; resume in a fresh session or trim the conversation`);return W(o,b,a),n?.onStat?.({sid:o,seq:e.seq,persist_ms:performance.now()-i,bytes:Buffer.byteLength(g),dir_bytes:T,compacted:_===e.seq,soft_warned:C}),b}function je(t,r,e){let s=t.read(m);if(s===null)throw new h("CHECKPOINT_MISSING",`${r}: no ${m} \u2014 not a checkpoint session`);let n=Z(m,s),i=p=>{let{deltas:a,fulls:u}=ee(t);if(!p){let g=[...a.map(y),...u.map(w)];return{base:n,agent:null,kane:null,pointer:null,orphans:g}}let l=te(t,r,p),A=[...a.filter(g=>g>p.seq).map(y),...u.filter(g=>g>p.seq).map(w)];return{base:n,agent:{delta_items:l.items,binding:l.last.agent.binding,base_fingerprint:l.base_fingerprint,agent_state_schema:l.last.agent.agent_state_schema,...l.last.agent.usage_total?{usage_total:l.last.agent.usage_total}:{}},kane:l.last.kane,pointer:p,orphans:A,...l.fallback?{fallback:l.fallback}:{}}},o=e();try{return i(o)}catch(p){if(!(p instanceof h&&p.code==="CHECKPOINT_MISSING"))throw p;return i(e())}}function Fe(t,r){let e=[];for(let s of U(t).records)if(s.sid===r)for(let n of s.event_ids??[])e.push(n);return e}function Me(t,r,e,s,n){let i=n.verb??"extract",o=t.parse(e.store_watermark),p=o===null?null:t.resolveToken(o);if(o!==null&&p===null)throw new L(`watermark not in chain: ${e.store_watermark} names no record in this store (rebuilt or foreign?) \u2014 re-ground the session or abandon it`);let a=t.recordsSince(o),u=p===null?0:t.sessions().recordCount(r,p.seq),l=new Map;for(let c of a)c.sid===r&&l.set(c.seq,++u);let A=c=>l.get(c.seq)??0,g=new Set(e.applied_events),C=0,v=[];for(let c of a){if(typeof c.sid!="string"){C+=1;continue}if(c.sid===r){if((c.event_ids??[]).length===0){C+=1;continue}v.push(c)}}C>0&&n.onNote?.(`reconcile: skipped ${C} store record(s) not attributable to this session (pre-sid grace)`);let q=n.ownActors??["extract-agent","design-agent","owner"],_=[],P=[];for(let c of v){if(n.resent!==void 0&&(c.event_ids??[]).includes(n.resent))continue;let R=(c.event_ids??[]).filter(ne=>!g.has(ne));if(R.length===0)continue;P.push(...R);let O;try{O=n.composeReceipt(c,s,{verb:i,commitN:A(c),...n.ucRef?{ucRef:n.ucRef}:{},...n.typedBlockers?{typedBlockers:!0}:{},...n.ignoreGaps?.size?{ignoreGaps:n.ignoreGaps}:{}}).text}catch{O=`commit ${R[0]} at ${c.ts} \u2014 details unavailable (graph moved since)`}let $=c.review?.[0]?.by;$?.id&&!q.includes($.id)&&(O+=`
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{c as h}from"./chunk-E4GIGM5V.js";import{P as v,ta as O,xb as y,yb as G,zb as b}from"./chunk-PI7OXS62.js";import{f as i,g as a,i as S}from"./chunk-KU3YHPWZ.js";import{o as m}from"./chunk-HYJVYYAZ.js";var C=new Set([a.BELONGS_TO,a.SCOPED_TO]),N="re-pinned onto the use case's live version: its update changed nothing";function A(e,s){let n=e.tipOf(s);return e.superseded.has(n)?[]:b(e,n).filter(t=>t!==n).flatMap(t=>e.edgesInto(t).filter(r=>C.has(r.type)&&!e.superseded.has(r.src)))}function k(e,s){for(let n of e.edgesFrom(s)){if(S(n.type)?.pin?.comparesTo!=="dst_tip"||!e.superseded.has(n.dst))continue;let t=e.tipOf(n.dst);if(e.superseded.has(t)||e.nodeLabel.get(t)===i.USECASE&&!C.has(n.type))return!1}return!0}function U(e){let{store:s,graph:n,by:t}=e,r=A(n,e.ucTip);if(r.length===0)return{record:null,moved:0,errors:null};let c=n.tipOf(e.ucTip),l=r.flatMap(o=>[{kind:"retract",target:o.src,expectedCid:o.src,edgeEcid:o.ecid,reason:N,eventId:`repin:${o.ecid}`},{kind:"enhance",target:o.src,expectedCid:o.src,edges:[{type:o.type,src:o.src,dst:c,props:o.props}],eventId:`repin:${o.ecid}:live`}]),d=h({store:s,graph:n,ops:l,by:t,mintable:[],learn:!1,...e.sid?{sid:e.sid}:{}});return d.errors?{record:null,moved:0,errors:d.errors}:{record:d.record,moved:r.length,errors:null}}var L=new Set([i.USECASE,i.SCENARIO,i.AC,i.TEST]);function $(e,s){return!e.superseded.has(s)&&e.trust.get(s)!=="archived"}function f(e,s,n){let t=e.edgesFrom(s).find(r=>r.type===n);return t?e.tipOf(t.dst):null}function D(e,s,n){if(n===i.USECASE)return s;if(n===i.SCENARIO)return f(e,s,a.BELONGS_TO);if(n===i.AC){let t=f(e,s,a.SCOPED_TO);return t?e.nodeLabel.get(t)===i.USECASE?t:f(e,t,a.BELONGS_TO):null}if(n===i.TEST){let t=f(e,s,a.AUTOMATES);return t?f(e,t,a.BELONGS_TO):null}return null}function*x(e,s){for(let{cid:n,state:t}of e.staleList()){if(t==="superseded")continue;let r=e.nodeLabel.get(n);!r||!L.has(r)||!$(e,n)||D(e,n,r)===s&&(yield{cid:n,label:r})}}function T(e,s){for(let{cid:n}of x(e,s))if(y(e,n))return!0;return!1}function q(e,s){let n=new Set,t=!1,r=!0;for(let{cid:c,label:l}of x(e,s)){let d=G(e,c);if(l===i.USECASE)for(let o of d.sources)n.add(o);else d.sources.length>0&&([t,r]=[!0,!1]);d.pin&&([t,r]=[!0,r&&k(e,c)])}return{sources:[...n].sort(),design:t,repinnable:t&&r}}var z=e=>e.sources.length>0&&!e.design;function _(e,s){let n=null;for(let[t,r]of e.designOf)t!==s&&e.tipOf(t)!==s||(n==null||r.seq>n.seq)&&(n={...r,designed_at_cid:t});return n}function F(e,s){let n=_(e,s);if(n!=null)return n.designed_at_cid===s||!T(e,s)?"current":"stale"}function R(e,s){let n=O(e.superseded,c=>e.nodeLabel.get(c)),t=[s],r=s;for(;n.has(r);)r=n.get(r),t.unshift(r);return t}function Y(e,s,n){let t=v(e,s);if(!t.ok&&t.why==="unknown"){let u=[...e.names.keys()].filter(w=>w.startsWith("uc-")).sort().slice(0,6);return{ok:!1,code:2,message:`unknown use-case '${s}' \u2014 no live node by that logical id or cid${u.length?` (known: ${u.join(", ")})`:""}`}}if(!t.ok&&t.why==="removed")return{ok:!1,code:2,message:`use-case '${s}' was removed (tombstoned) \u2014 nothing to design`};if(!t.ok)return{ok:!1,code:2,message:`'${s}' is a ${t.label??"missing node"}, not a use-case \u2014 design runs per use-case`};let r=t.cid,c=e.resolve(s)?.cid,l=e.nameOf.get(r)??(c?e.nameOf.get(c):void 0)??e.displayNameOf(r)??r.slice(0,19);if(e.trust.get(r)==="archived"){let u=e.archivedReason.get(r);return{ok:!1,code:2,message:`use-case '${l}' is archived${u?` (${u})`:""} \u2014 design runs only over live use-cases`}}let d=_(e,r);if(d==null||n)return{ok:!0};let o=R(e,r),p=o.length;if(F(e,r)==="current")return{ok:!1,code:2,message:m().text("note.already_designed",{use_case:l,version:p}),wall:{kind:"already-designed",display:l,currentV:p}};let g=o.indexOf(d.designed_at_cid),E=g>=0?`v${g+1}`:"an earlier version";return{ok:!1,code:2,message:m().text("note.design_stale",{use_case:l,designed:E,current:p}),wall:{kind:"designed-stale",display:l,currentV:p,designedV:E}}}export{U as a,L as b,$ as c,D as d,T as e,q as f,z as g,_ as h,F as i,Y as j};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as ne,b as te,c as re,d as ie,e as z}from"./chunk-WXJCJL5L.js";import{b as se,c as oe}from"./chunk-IINZZ4BZ.js";import{n as ee,p as j}from"./chunk-NC7D7GOM.js";import{a as $e}from"./chunk-6YGTRKDT.js";import{e as Te}from"./chunk-UR6MHSHU.js";function Oe(r){let e=r==="passed"?"passed":"failed";return{testStatus:e,remark:`kane-cli: ${e}`}}var Le={testStatus:"failed",remark:"cancelled"};var Ae="https://www.testmuai.com/pricing/",De=/Real Mobile App Automation not allowed on your current plan/i,L=class extends Error{code="plan_required";constructor(e){super(e),this.name="RealDevicePlanError"}};function ae(r){return!r||!De.test(r)?null:["Real devices aren't included in your TestMu AI plan.","Running on a real device needs the KaneAI Max or Real Device Plus Automation Cloud plan.",`See plans: ${Ae}`].join(`
2
+ import{a as ne,b as te,c as re,d as ie,e as z}from"./chunk-DXLZCJH5.js";import{b as se,c as oe}from"./chunk-IINZZ4BZ.js";import{n as ee,p as j}from"./chunk-UJLULWSR.js";import{a as $e}from"./chunk-6YGTRKDT.js";import{e as Te}from"./chunk-UR6MHSHU.js";function Oe(r){let e=r==="passed"?"passed":"failed";return{testStatus:e,remark:`kane-cli: ${e}`}}var Le={testStatus:"failed",remark:"cancelled"};var Ae="https://www.testmuai.com/pricing/",De=/Real Mobile App Automation not allowed on your current plan/i,L=class extends Error{code="plan_required";constructor(e){super(e),this.name="RealDevicePlanError"}};function ae(r){return!r||!De.test(r)?null:["Real devices aren't included in your TestMu AI plan.","Running on a real device needs the KaneAI Max or Real Device Plus Automation Cloud plan.",`See plans: ${Ae}`].join(`
3
3
  `)}function ue(r){return{command:"start",...r}}function de(r,e,s){return{command:"run",run_id:r,kind:e,...s}}function le(r){return{command:"cancel",...r?{run_id:r}:{}}}function ce(r){return{command:"ask_user_response",answer:r}}function pe(r={}){return{command:"shutdown",...r.testStatus?{test_status:r.testStatus,remark:r.remark??""}:{}}}var W=Symbol("run-queue-end"),J=class{items=[];waiting=null;ended=!1;error=null;push(e){if(this.waiting){let{resolve:s}=this.waiting;this.waiting=null,s(e)}else this.items.push(e)}end(){if(this.ended=!0,this.waiting){let{resolve:e}=this.waiting;this.waiting=null,e(W)}}fail(e){if(this.error=e,this.waiting){let{reject:s}=this.waiting;this.waiting=null,s(e)}}next(){return this.items.length>0?Promise.resolve(this.items.shift()):this.error?Promise.reject(this.error):this.ended?Promise.resolve(W):new Promise((e,s)=>{this.waiting={resolve:e,reject:s}})}},F=class{env;runner;log;sessionId;spawnFn;proc=null;activeRun=null;pendingReady=null;shuttingDown=!1;finalized=!1;exitInfo=null;exitedUnexpectedly=!1;exitResolve;onEvent;exited;constructor(e){this.env=e.env,this.runner=e.runner,this.log=e.log,this.sessionId=e.sessionId,this.spawnFn=e.spawn??te,this.onEvent=e.onEvent;let s;this.exited=new Promise(d=>{s=d}),this.exitResolve=s}async start(e){if(this.proc)throw new Error("PersistentRunner.start called twice");this.proc=this.spawnFn({env:this.env,runner:this.runner,log:this.log,sessionId:this.sessionId}),this.consume();let s=new Promise((d,g)=>{this.pendingReady={resolve:d,reject:g}});this.writeCommand(ue(e)),await s}async*run(e,s,d){if(!this.proc)throw new Error("PersistentRunner.run called before start");if(this.finalized)throw new Error(`v16-runner is not running (exited code=${this.exitInfo?.code??"null"}, signal=${this.exitInfo?.signal??"none"}) \u2014 cannot start run '${e}'`);if(this.activeRun)throw new Error(`PersistentRunner.run overlap: '${this.activeRun.runId}' still in flight`);let g=new J,_={runId:e,queue:g};this.activeRun=_,this.writeCommand(de(e,s,d));try{for(;;){let v=await g.next();if(v===W||(yield v,v.type==="run_end"&&(v.run_id===void 0||v.run_id===e)))break}}finally{this.activeRun===_&&(this.activeRun=null)}}sendUserResponse(e){this.writeCommand(ce(e))}cancel(e){this.writeCommand(le(e))}kill(){this.proc?.child.kill("SIGTERM")}async shutdown(e={}){this.shuttingDown=!0,this.proc&&(this.writeCommand(pe(e)),await this.exited)}get stderr(){return this.proc?.getStderr()??""}get diedUnexpectedly(){return this.exitedUnexpectedly}writeCommand(e){let s=JSON.stringify(e)+`
4
4
  `;try{this.proc?.child.stdin?.write(s)}catch{}}async consume(){if(!this.proc)return;try{for await(let d of this.proc.events){if(d.type==="ready"){this.onReady();continue}if(d.type==="error"&&this.pendingReady){this.onStartError(d.message);continue}try{this.onEvent?.(d)}catch{}this.routeEvent(d)}}catch(d){this.log?.("error","PERSISTENT_RUNNER_STREAM_ERROR","Runner stdout stream errored",{error:d instanceof Error?d.message:String(d)})}let{code:e,signal:s}=await this.proc.exited;this.onExit(e,s)}onReady(){if(this.pendingReady){let{resolve:e}=this.pendingReady;this.pendingReady=null,e()}}onStartError(e){if(!this.pendingReady)return;let{reject:s}=this.pendingReady;this.pendingReady=null;let d=ae(e);if(d){this.log?.("error","REAL_DEVICE_PLAN_REQUIRED","The mobile hub refused the session over the plan",{reason:e}),s(new L(d));return}s(new Error(`failed to start: ${e??"unknown error"}`))}routeEvent(e){let s=this.activeRun;if(!s){this.log?.("warn","PERSISTENT_RUNNER_ORPHAN_EVENT","Runner event with no active run",{event_type:e.type});return}s.queue.push(e)}onExit(e,s){if(!this.finalized){if(this.finalized=!0,this.exitInfo={code:e,signal:s},this.shuttingDown||(this.exitedUnexpectedly=!0),this.exitResolve({code:e,signal:s}),this.pendingReady){let{reject:d}=this.pendingReady;this.pendingReady=null,d(new Error(`v16-runner exited before ready (code=${e}, signal=${s??"none"})`))}if(this.activeRun){let{queue:d}=this.activeRun;if(this.activeRun=null,this.shuttingDown)d.end();else{let g=this.proc?.getStderr()?.slice(-500)??"";d.fail(new Error(`v16-runner exited unexpectedly mid-run (code=${e}, signal=${s??"none"})${g?`
5
5
  ${g}`:""}`))}}}}};var p=Te($e(),1);function he(r){let e={cdp_endpoint:r.cdp_endpoint,ws_endpoint:r.ws_endpoint,width:r.width,height:r.height,headless:r.headless,model:r.model,max_steps:r.max_steps,network_ws:r.network_ws,network_sse:r.network_sse,session_id:r.session_id};return r.device&&(e.device=r.device),r.auth&&(e.auth=r.auth),r.project_id&&(e.project_id=r.project_id),r.disable_ask_user&&(e.disable_ask_user=!0),r.media_upload&&(e.media_upload=r.media_upload),r.username&&(e.username=r.username),r.access_key&&(e.access_key=r.access_key),e}function N(r,e){let s=null,d=(g,_)=>{for(let v=0;v<g.length;v++){let E=g[v],h=[..._,v];e(E)&&(s===null||h.length>s.length)&&(s=h),E.children&&E.children.length>0&&d(E.children,h)}};return d(r,[]),s}function T(r,e,s){if(e.length===0)return[...r];let d=e[0],g=[...r],_=g[d];if(e.length===1)g[d]=s(_);else{let v=e.slice(1),E=T(_.children??[],v,s);g[d]={..._,children:E}}return g}var Ue=6e4;function fe(){return{steps:[],maxOrdinal:0}}function Me(r,e){if(e.type==="run_start"&&e.child_id)return e.environment?.resolution?{...r,resolution:e.environment.resolution}:r;if(e.type==="run_start"){let s=oe(r.runnerEnvironment,se(e.environment));if(s)return{...r,runnerEnvironment:s,...s.resolution?{resolution:s.resolution}:{}}}if(e.type==="step_end"&&typeof e.ordinal=="number"&&e.id){let s={id:e.id,ordinal:e.ordinal,status:e.status,...e.kind?{kind:e.kind}:{},...typeof e.duration=="number"?{duration_ms:Math.round(e.duration*1e3)}:{},...typeof e.action_id=="string"&&e.action_id?{action_id:e.action_id}:{}};return{...r,steps:[...r.steps,s],maxOrdinal:Math.max(r.maxOrdinal,e.ordinal)}}return r}function H(r){let e=r.indexOf(": ");return e>0&&e<15?r.slice(e+2):r}function Q(r){return r.map(e=>{let s=e.children?Q(e.children):e.children;return e.status==="running"?{...e,status:"stopped",phase:void 0,children:s}:s!==e.children?{...e,children:s}:e})}function nn(r,e,s,d,g){let[_,v]=(0,p.useState)(!1),[E,h]=(0,p.useState)([]),[me,$]=(0,p.useState)(null),[ve,B]=(0,p.useState)(null),[ge,C]=(0,p.useState)(null),[Re,X]=(0,p.useState)(null),[Se,Y]=(0,p.useState)([]),[ye,Z]=(0,p.useState)(null),[we,xe]=(0,p.useState)(void 0),[_e,A]=(0,p.useState)(0),x=(0,p.useRef)(null),D=(0,p.useRef)(null),k=(0,p.useRef)(null),w=(0,p.useRef)(null),b=(0,p.useRef)(0),V=(0,p.useRef)(!1),U=(0,p.useRef)(fe()),M=(0,p.useRef)(null),Ee=(0,p.useCallback)(async(f,S)=>{let I=M.current;if(I)try{await I}catch{}h([]),$(null),B(null),C(null),X(null),Y([]),Z(null),xe(f.max_steps),v(!0),w.current=null,b.current=0,U.current=fe();let y=x.current;if(y&&k.current!==f.session_id){try{y.kill()}catch{}x.current=null,k.current=null,A(n=>n+1),y=null}if(!y){let n=ne();if(!n){C("v16-runner not found. Build the binary with `cd v16-runner && python build.py` or ensure Python is available."),v(!1);return}let l=ie({environment:S?.environment,mode:S?.mode,assertionMode:S?.assertionMode,finalValidation:S?.finalValidation,username:f.username,accessKey:f.access_key,sessionId:f.session_id});f.device?.platform&&await re(l,f.device);let u=new F({env:l,runner:n,log:S?.log,sessionId:f.session_id,...S?.onRunnerEvent?{onEvent:S.onRunnerEvent}:{}});x.current=u,k.current=f.session_id,y=u,ee("runner",()=>{try{u.kill()}catch{}});let o={...f};z(o,{environment:S?.environment});let a=he(o);try{await u.start(a)}catch(t){C(t instanceof Error?t.message:String(t)),v(!1),j("runner","Runner start failed"),x.current=null,k.current=null,A(i=>i+1);return}}let q={...f};delete q.run_id,z(q,{environment:S?.environment});let je=`run-${f.run_index}`,Ne=f.mode==="replay"?"replay":"author",G=y,K=(async()=>{V.current=!1;for await(let n of G.run(je,Ne,q)){if(V.current)break;switch(U.current=Me(U.current,n),n.type){case"run_start":if(n.child_id)break;if(w.current&&!w.current.isSingleFlow){let l=b.current;b.current++,h(u=>u.map((o,a)=>a===l?{...o,status:"running"}:o.status==="running"&&!o.children?.some(t=>t.status==="running")?{...o,status:o.children?.some(t=>t.status==="failed")?"failed":"passed"}:o))}break;case"bifurcation":{let l=n.flows??[],u=n.count??l.length,o={flows:l,isSingleFlow:n.is_single_flow??u<=1};X(o),w.current=o,b.current=0,h(l.map((a,t)=>({index:t+1,objective:a??`Flow ${t+1}`,status:"pending"})));break}case"step_start":{e?.("STEP_START",`Step ${n.index} started`,{index:n.index,objective:n.objective,child_id:n.child_id});let l=n.index,u=n.objective??`Step ${l}`,o=n.child_id,a=w.current&&!w.current.isSingleFlow;if(o)h(t=>{let i=N(t,c=>c.branchChildId===o)??N(t,c=>c.status==="running");return i?T(t,i,c=>{let m=(c.children??[]).map(R=>R.status==="running"&&R.childId===o?{...R,status:"stopped",phase:void 0}:R);return m.push({index:l,objective:u,status:"running",childId:o}),{...c,children:m}}):t});else if(a){let t=Math.max(0,b.current-1);h(i=>{let c=[...i];if(t>=c.length)return i;let m={...c[t]},P=[...m.children??[]].map(O=>O.status==="running"&&O.childId===void 0?{...O,status:"stopped",phase:void 0}:O);return P.push({index:l,objective:u,status:"running"}),m.children=P,m.status="running",c[t]=m,c})}else h(t=>{let i=Q(t);return i.some(m=>m.index===l)?i.map(m=>m.index===l?{...m,status:"running",objective:u}:m):[...i,{index:l,objective:u,status:"running"}]});break}case"step_event":{e?.("STEP_EVENT",`Step ${n.index} ${n.event}`,{index:n.index,phase:n.event,action_type:n.action_type,detail:n.detail,child_id:n.child_id});let l=n.child_id,u=w.current&&!w.current.isSingleFlow;if(n.event==="cm_init"&&n.checkpoint_count!=null){Y(o=>[...o,n.checkpoint_count]);break}if(n.event==="replay_started"){Z({recordingLength:n.recording_length??0});break}if(n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&s?.(n.detail),l){let o=t=>{if(t.index!==n.index||t.childId!==l)return t;let i={phase:n.event};return n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(i.objective=n.detail),n.action_type&&(i.actionType=n.action_type),{...t,...i}},a=t=>t.map(i=>{let c=o(i);return c!==i?c:i.children&&i.children.length>0?{...i,children:a(i.children)}:i});h(t=>t.map(i=>i.children?{...i,children:a(i.children)}:i))}else if(u){let o=Math.max(0,b.current-1);h(a=>{let t=[...a];if(o>=t.length)return a;let i={...t[o]},c=[...i.children??[]];if(!c.some(R=>R.index===n.index&&R.childId===void 0))c.push({index:n.index,objective:`Step ${n.index}`,status:"running",phase:n.event,actionType:n.action_type});else for(let R=0;R<c.length;R++){if(c[R].index!==n.index||c[R].childId!==void 0)continue;let P={phase:n.event};n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(P.objective=n.detail),n.action_type&&(P.actionType=n.action_type),c[R]={...c[R],...P}}return i.children=c,t[o]=i,t})}else h(o=>o.some(t=>t.index===n.index)?o.map(t=>{if(t.index!==n.index)return t;let i={phase:n.event};return n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(i.objective=n.detail),n.action_type&&(i.actionType=n.action_type),{...t,...i}}):[...Q(o),{index:n.index,objective:`Step ${n.index}`,status:"running",phase:n.event,actionType:n.action_type}]);break}case"step_end":{e?.("STEP_END",`Step ${n.index} ${n.status}`,{index:n.index,status:n.status,duration:n.duration,summary:n.summary,child_id:n.child_id}),d?.();let l=n.child_id,u=w.current&&!w.current.isSingleFlow;if(l){let o=t=>t.index===n.index&&t.childId===l?{...t,status:n.status,duration:n.duration,phase:void 0,objective:t.objective.startsWith("Step ")?H(n.summary||t.objective):t.objective}:t,a=t=>t.map(i=>{let c=o(i);return c!==i?c:i.children&&i.children.length>0?{...i,children:a(i.children)}:i});h(t=>t.map(i=>i.children?{...i,children:a(i.children)}:i))}else if(u){let o=Math.max(0,b.current-1);h(a=>{let t=[...a];if(o>=t.length)return a;let i={...t[o]},c=(i.children??[]).map(m=>m.index===n.index&&m.childId===void 0?{...m,status:n.status,duration:n.duration,phase:void 0,objective:m.objective.startsWith("Step ")?H(n.summary||m.objective):m.objective}:m);return i.children=c,t[o]=i,t})}else h(o=>o.map(a=>a.index===n.index?{...a,status:n.status,duration:n.duration,phase:void 0,objective:a.objective.startsWith("Step ")?H(n.summary||a.objective):a.objective}:a));{let a=w.current&&!w.current.isSingleFlow?Math.max(0,b.current-1):0,t=typeof n.ordinal=="number"&&n.id?{ordinal:n.ordinal,id:n.id}:void 0;r?.(n.index,a,n.child_id,t)}break}case"child_agent_start":{let l=n.objective??"",u=n.child_id;h(o=>{let a=N(o,t=>t.status==="running");return a?T(o,a,t=>({...t,objective:`${l} (branch)`,phase:`child: ${l.slice(0,50)}`,branchObjective:l,branchChildId:u})):o});break}case"child_agent_end":{let l=n.child_id,u=`child ${n.success?"done":"failed"}`;h(o=>{let a=N(o,t=>t.branchChildId===l);return a?T(o,a,t=>({...t,phase:u})):o.map(t=>t.phase?.startsWith("child:")?{...t,phase:u}:t)});break}case"describe_trigger":g?.(n);break;case"ask_user":$(n.question??"");break;case"run_end":h(l=>l.map(u=>u.status==="running"?{...u,status:n.status,phase:void 0}:u)),v(!1),B(n);break;case"error":v(!1),C(n.message??"Runner error"),h(l=>l.map(u=>u.status==="running"?{...u,status:"failed",phase:void 0}:u));break}}})().catch(n=>{if(x.current!==G)return;let u=[n instanceof Error?n.message:String(n)],o=G.stderr;o&&!u.join(`
@@ -0,0 +1,12 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{b as l}from"./chunk-NVD2MXHQ.js";import{e as d,h as p}from"./chunk-XMPTFXPW.js";import{b as f}from"./chunk-REKHAN53.js";import{Ha as i,s as g}from"./chunk-H4TIVILC.js";import{a as c}from"./chunk-FOJHSG5M.js";var h=new Set(["context extract","design tests","context sessions","context ingest","context list","maintain reconcile","maintain evolve","cover","context pull","context impact"]),I=new Set(["context ingest","context extract"]),y=new Set(["testmd run","testrun run"]),w=new Set(["context","design","maintain","cover"]);function $(e,n){return n.kind==="local"||n.kind==="pick"||!w.has(e.split(" ")[0])?null:n.kind==="refuse"?n.refusal:w.has(e)||h.has(e)||y.has(e)?null:i.notYet(e)}var R={tests:"design",sessions:"save","sessions discard":"discard",ingest:"extract",list:"list",reconcile:"reconcile"};function a(e,n,t){return t?p(d("ndjson",R[n]??n),e.message,e.code,e.remedy):(k(e),2)}function G(e,n,t){if(e.code!=="LIST_FAILED"&&e.code!=="COVERAGE_FAILED")return a(e,n,t);if(t){let r=d("ndjson",R[n]??n);return r.event({type:"error",code:e.code,message:e.message,...e.remedy?{remedy:e.remedy}:{}}),r.done(1)}return k(e),1}function E(e,n){if(!e.answer?.length)return null;let t=f({answer:e.answer});return t.ok?e.resume?e.mode!=="agent"?i.answerAgentOnly(n,e.resume):null:i.answerNeedsResume():i.answerParse(t.error)}function v(e,n){if(!e.answer?.length||l(process.cwd()).kind!=="remote")return null;let t=E(e,n);return t===null?null:a(t,n.split(" ")[1],e.mode==="agent")}var B=e=>`${c.green(`\u2713 Project: "${e}"`)}
3
+ ${c.dim(" this folder is now linked to it; what you save goes to the project")}
4
+ `;function k(e){if(process.stderr.write(`${u(`error: ${e.message}`)}
5
+ `),e.detail&&process.stderr.write(`${c.dim(` ${e.detail}`)}
6
+ `),e.remedy){let[n,...t]=e.remedy.split(`
7
+ `);process.stderr.write(`${u(`next: ${n}`,!0,e.ownLine)}
8
+ `);for(let r of t)process.stderr.write(`${r}
9
+ `)}e.support&&process.stderr.write(`${u(`if this keeps failing, share this id with support: ${g(`refused_${e.code}`)}`)}
10
+ `)}function u(e,n=!1,t=!1){let r=process.stderr.columns;if(!r||e.length<=r&&!t)return e;let s=e.lastIndexOf(": ");return n&&s>=0&&/^(kane-cli|npm|brew) /.test(e.slice(s+2))?`${x(e.slice(0,s+1),r)}
11
+ ${e.slice(s+2)}`:x(e,r)}function x(e,n){let t=[],r=e;for(;r.length>n;){let s=r.lastIndexOf(" ",n);if(s<=0)break;t.push(r.slice(0,s)),r=r.slice(s+1)}return[...t,r].join(`
12
+ `)}var A=e=>e.mode==="agent"||e.agent===!0;function L(e){e.hook("preAction",(n,t)=>{let r=[];for(let o=t;o!==null&&o.parent!==null;o=o.parent)r.unshift(o.name());let s=l(process.cwd()),m=$(r.join(" "),s);if(r.join(" ")==="cover"&&s.kind==="remote"&&t.args.length>0&&t.error(`error: unknown command '${t.args[0]}'`,{exitCode:2}),m===null)return;let S=t.name()==="sessions"&&t.args[0]==="discard"?"sessions discard":t.name();process.exit(a(m,S,A(t.opts())))})}export{h as a,I as b,y as c,w as d,$ as e,a as f,G as g,E as h,v as i,B as j,k,x as l,A as m,L as n};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as h}from"./chunk-LX2I4JEH.js";import{c as u}from"./chunk-XB6BJPDL.js";import{oa as f}from"./chunk-UEE3RZN4.js";import{f as p}from"./chunk-KU3YHPWZ.js";function g(o,n){let t=o.recordsSince(null),i=new Set;for(let e of t)for(let r of e.review)r.resolution!=="pending"&&i.add(r.id);let s=[],c=new Set;for(let e=t.length-1;e>=0;e--)for(let r of t[e].dedup_hits??[]){if(r.new_cid===void 0)continue;let a=`${r.new_cid}|${r.candidate_cid}`;c.has(a)||(c.add(a),!i.has(r.new_cid)&&(n.superseded.has(r.new_cid)||n.superseded.has(r.candidate_cid)||n.trust.get(r.new_cid)==="derived"&&s.push({new_cid:r.new_cid,candidate_cid:r.candidate_cid,score:r.score,scorer:r.scorer})))}return s}var d=(o,n)=>o.displayNameOf(n)??n.slice(0,19);function w(o,n){return{design_children:o.edgesInto(n).filter(i=>(i.type==="belongs_to"||i.type==="scoped_to")&&!o.superseded.has(i.src)).length}}function v(o,n){let t=o.recordsSince(null),i=new Set,s=new Map;for(let e of t)for(let r of e.review)r.kind==="pending_archive"?s.set(r.id,r.reason):r.resolution!=="pending"&&i.add(r.id);let c=new Map;for(let[e,r]of s)n.superseded.has(e)||n.trust.get(e)!=="derived"||i.has(e)||c.set(e,r);return{all:s,live:c}}function R(o,n){o.store.prefetch(u(n),{token:null});let t=[],i=new Set;for(let e of g(o.store,n)){i.add(e.new_cid);let r=e.scorer==="lexical_fallback"?" (lexical fallback \u2014 the probe ran degraded)":"";t.push({kind:"PAIR",ref:d(n,e.new_cid),title:String(n.getNode(e.new_cid)?.content.title??e.new_cid.slice(0,12)),why:`possible duplicate of ${d(n,e.candidate_cid)} \u2014 score ${e.score}${r}`,pair:{candidate_cid:e.candidate_cid,candidate_ref:d(n,e.candidate_cid),score:e.score,scorer:e.scorer}})}let{all:s,live:c}=v(o.store,n);for(let[e,r]of c)t.push({kind:"REVIEW",ref:d(n,e),title:String(n.getNode(e)?.content.title??e.slice(0,12)),why:`archive held for interactive confirmation${r?` \u2014 ${r}`:""}`,held:!0,impact:w(n,e)});for(let e of y(o.store))t.push({kind:"MODIFY_HELD",ref:`${e.sid}:${e.tempRef}`,title:String(e.content.title??e.tempRef),why:`${e.rationale} \u2014 held by paused/dead session ${e.sid}`,heldPayload:e});for(let{cid:e,content:r}of n.byLabel(p.USECASE)){if(n.superseded.has(e)||n.trust.get(e)!=="derived"||i.has(e)||s.has(e))continue;let{sources:a,missing:l}=h(n,e),m=l.length===0?"":`; CITE_MISSING: ${l.map(_=>f(d(n,_))).join(", ")} cite nothing of ${a.join(", ")}`;t.push({kind:"REVIEW",ref:d(n,e),title:String(r.title??e.slice(0,12)),why:`unreviewed \u2014 approve, archive, or defer${m}`,impact:w(n,e)})}return t}function $(o,n){let t={REVIEW:0,PAIR:0,MODIFY_HELD:0};for(let i of R(o,n))t[i.kind]++;return t}function y(o){let n=[],t=o.sessions();for(let{sid:i}of t.list()){if(t.isLive(i))continue;let s=[],c=!1;try{let r=t.loadCheckpoint(i).kane;r?.pending?.proposals?.length&&(s=r.pending.proposals,c=!0)}catch{c=!1}if(!c)try{let e=t.peek(i);if(!e)continue;s=(e.pending?.proposals??[]).map(r=>({...r}))}catch{continue}for(let e of s)n.push({sid:i,tempRef:String(e.tempRef??e.temp_ref??"held"),...typeof e.event_id=="string"?{event_id:e.event_id}:{},label:String(e.label??"usecase"),content:e.content??{},rationale:String(e.rationale??"held payload")})}return n}export{w as a,v as b,R as c,$ as d};
2
+ import{b as h}from"./chunk-LX2I4JEH.js";import{c as u}from"./chunk-XB6BJPDL.js";import{oa as f}from"./chunk-PI7OXS62.js";import{f as p}from"./chunk-KU3YHPWZ.js";function g(o,n){let t=o.recordsSince(null),i=new Set;for(let e of t)for(let r of e.review)r.resolution!=="pending"&&i.add(r.id);let s=[],c=new Set;for(let e=t.length-1;e>=0;e--)for(let r of t[e].dedup_hits??[]){if(r.new_cid===void 0)continue;let a=`${r.new_cid}|${r.candidate_cid}`;c.has(a)||(c.add(a),!i.has(r.new_cid)&&(n.superseded.has(r.new_cid)||n.superseded.has(r.candidate_cid)||n.trust.get(r.new_cid)==="derived"&&s.push({new_cid:r.new_cid,candidate_cid:r.candidate_cid,score:r.score,scorer:r.scorer})))}return s}var d=(o,n)=>o.displayNameOf(n)??n.slice(0,19);function w(o,n){return{design_children:o.edgesInto(n).filter(i=>(i.type==="belongs_to"||i.type==="scoped_to")&&!o.superseded.has(i.src)).length}}function v(o,n){let t=o.recordsSince(null),i=new Set,s=new Map;for(let e of t)for(let r of e.review)r.kind==="pending_archive"?s.set(r.id,r.reason):r.resolution!=="pending"&&i.add(r.id);let c=new Map;for(let[e,r]of s)n.superseded.has(e)||n.trust.get(e)!=="derived"||i.has(e)||c.set(e,r);return{all:s,live:c}}function R(o,n){o.store.prefetch(u(n),{token:null});let t=[],i=new Set;for(let e of g(o.store,n)){i.add(e.new_cid);let r=e.scorer==="lexical_fallback"?" (lexical fallback \u2014 the probe ran degraded)":"";t.push({kind:"PAIR",ref:d(n,e.new_cid),title:String(n.getNode(e.new_cid)?.content.title??e.new_cid.slice(0,12)),why:`possible duplicate of ${d(n,e.candidate_cid)} \u2014 score ${e.score}${r}`,pair:{candidate_cid:e.candidate_cid,candidate_ref:d(n,e.candidate_cid),score:e.score,scorer:e.scorer}})}let{all:s,live:c}=v(o.store,n);for(let[e,r]of c)t.push({kind:"REVIEW",ref:d(n,e),title:String(n.getNode(e)?.content.title??e.slice(0,12)),why:`archive held for interactive confirmation${r?` \u2014 ${r}`:""}`,held:!0,impact:w(n,e)});for(let e of y(o.store))t.push({kind:"MODIFY_HELD",ref:`${e.sid}:${e.tempRef}`,title:String(e.content.title??e.tempRef),why:`${e.rationale} \u2014 held by paused/dead session ${e.sid}`,heldPayload:e});for(let{cid:e,content:r}of n.byLabel(p.USECASE)){if(n.superseded.has(e)||n.trust.get(e)!=="derived"||i.has(e)||s.has(e))continue;let{sources:a,missing:l}=h(n,e),m=l.length===0?"":`; CITE_MISSING: ${l.map(_=>f(d(n,_))).join(", ")} cite nothing of ${a.join(", ")}`;t.push({kind:"REVIEW",ref:d(n,e),title:String(r.title??e.slice(0,12)),why:`unreviewed \u2014 approve, archive, or defer${m}`,impact:w(n,e)})}return t}function $(o,n){let t={REVIEW:0,PAIR:0,MODIFY_HELD:0};for(let i of R(o,n))t[i.kind]++;return t}function y(o){let n=[],t=o.sessions();for(let{sid:i}of t.list()){if(t.isLive(i))continue;let s=[],c=!1;try{let r=t.loadCheckpoint(i).kane;r?.pending?.proposals?.length&&(s=r.pending.proposals,c=!0)}catch{c=!1}if(!c)try{let e=t.peek(i);if(!e)continue;s=(e.pending?.proposals??[]).map(r=>({...r}))}catch{continue}for(let e of s)n.push({sid:i,tempRef:String(e.tempRef??e.temp_ref??"held"),...typeof e.event_id=="string"?{event_id:e.event_id}:{},label:String(e.label??"usecase"),content:e.content??{},rationale:String(e.rationale??"held payload")})}return n}export{w as a,v as b,R as c,$ as d};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as d,e as l}from"./chunk-4I7YN6YY.js";var h=e=>`'${e.replace(/'/g,"'\\''")}'`,u=e=>e!==void 0?` --mode ${e}`:"",s=({verb:e,sid:t,mode:n})=>e==="design"?`kane-cli design tests --resume ${t}${u(n)}`:`kane-cli context extract --resume ${t}${u(n)}`,g=({ref:e,because:t,answers:n})=>`kane-cli maintain evolve ${e??"--from-stale"}${t?` --because ${h(t)}`:""} --mode agent`+n.map(i=>` --answer ${i.id}=${i.choice==="proceed"?1:2}`).join(""),r=e=>`kane-cli context extract --resume ${e}`,$=e=>/^[\w@%+=:,./-]+$/.test(e)?e:h(e),a=e=>e?`to review its source's change, run: ${e}`:"review its source's change with kane-cli maintain reconcile first",o="re-run kane-cli maintain reconcile to re-stage",c=e=>`retire it first (kane-cli context retire ${e}) or ingest under a different id with --as`,_=d({commands:{"next.resume_session":s,"next.resume_with_message":e=>`${s(e)} --message "<your words>"`,"next.resume_child":({sid:e})=>`kane-cli design tests --resume ${e}`,"next.design_use_case":({use_case:e,force:t})=>`kane-cli design tests --use-case ${e}${t?" --force":""}`,"next.review_use_case":({use_case:e})=>`kane-cli context review --approve ${e}`,"next.design_unreviewed":({use_case:e})=>`kane-cli design tests --use-case ${e} --mode agent --allow-unreviewed`,"next.view_design":({use_case:e})=>`kane-cli context view ${e}`,"next.evolve_design":({use_case:e})=>`kane-cli maintain evolve ${e}`,"next.redesign":({use_case:e})=>`kane-cli design tests --use-case ${e} --force --mode agent`,"next.design_phase":({use_case:e,phase:t,agent_mode:n})=>`kane-cli design tests --use-case ${e} --phase ${t}${n?" --mode agent":""}`,"next.answer_evolve":g,"next.abandon_session":({sid:e})=>`kane-cli context sessions clean ${e}`,"next.review_held_changeset":()=>"kane-cli maintain reconcile --apply","next.show_session":({sid:e})=>`kane-cli context sessions show ${e}`,"next.review_source":({source_id:e,from:t,agent_mode:n})=>t===null?null:`kane-cli maintain reconcile --from ${$(t)}${/^https?:\/\//.test(t)?"":` --source-id ${e}`}${n?" --mode agent":""}`},texts:{...l,"note.paused":e=>e.verb==="design"?`paused \u2014 resume with: ${s(e)}`:`paused: session ${e.sid} saved \u2014 resume with: ${s(e)}`,"note.crashed":e=>`agent crashed \u2014 session ${e.sid} is resumable at checkpoint seq ${e.seq} (at most the in-flight turn lost); resume with: ${s(e)}`,"note.model_unavailable_kept":e=>`the model service did not answer (${e.detail}) \u2014 session ${e.sid} is kept; resume with: ${s(e)}`,"note.model_retry":({seconds:e})=>`the model service is not answering; trying again in ${e}s`,"note.already_extracted":({source_id:e})=>`${e} already extracted \u2014 skipped (--force re-runs it)`,"note.conversation_source_skipped":({source_id:e})=>`skipped ${e} \u2014 conversation source; extract it explicitly with --source ${e}`,"note.reconcile_plan_pending":({source_id:e,pending:t,path:n})=>`note: a reconcile plan for ${e} is pending (${t} item(s)) \u2014 resume with \`kane-cli maintain reconcile --apply ${n}\``,"note.nothing_to_extract":({sources:e,count:t})=>`extract: nothing to do \u2014 ${e} ${t===1?"is":"are all"} already extracted at the current snapshot (--force to re-run)`,"note.only_conversation_sources":()=>"extract: nothing to do \u2014 only conversation sources here (extract one explicitly with --source <id>)","note.all_extracted":()=>"extract: nothing to do \u2014 every ingested source is already extracted","note.changeset_held_for_review":({held:e})=>`paused: ${e} held change(s) await your verdicts \u2014 review them in a terminal: kane-cli maintain reconcile --apply`,"note.held_for_review":({sid:e,mode:t,held:n})=>`paused: ${n} held item(s) await review \u2014 resume with: ${s({verb:"extract",sid:e,mode:t})}`,"note.session_kept":e=>`session ${e.sid} kept its last checkpoint (seq ${e.seq}, ${e.ts}) \u2014 resume with: ${s(e)}`,"note.assumed_defaults":({sid:e,count:t})=>`note: ${t} default(s) were assumed while you were away \u2014 kane-cli context sessions show ${e} lists them`,"note.landed_changed":({source_id:e})=>`note: ${e} changed after it was added \u2014 skipping its extraction this run; re-run kane-cli context extract to pick up the newer version`,"note.landed_older_queued":({source_id:e})=>`note: an older version of ${e} is already queued this run \u2014 the newly landed version is not extracted; re-run kane-cli context extract to pick it up`,"note.reingest_binary":({source_id:e,kind:t})=>`skipping ${e}: binary ${t} ingested before image support \u2014 re-ingest it (kane-cli context ingest) to extract from it`,"note.schedule_refused":()=>"this run holds items for review, so its extraction is not scheduled \u2014 kane-cli context extract runs it after the review","note.not_reached":()=>"run ended before its turn \u2014 kane-cli context extract runs it","note.nothing_committed":({source_id:e,remaining:t})=>`done \u2014 nothing committed for ${e} (no finalize before the session ended)`+(t>0?`; stopping here \u2014 ${t} remaining source(s) not extracted (re-run kane-cli context extract to continue)`:""),"note.landed_not_extracted":({count:e,sources:t})=>`note: ${e} source(s) landed this session (${t}) were not extracted \u2014 the session ended first; kane-cli context extract runs them`,"note.evidence_not_attached":({count:e})=>`note: ${e} unchanged match(es) target unreviewed (or no-longer-resolving) item(s) \u2014 evidence not attached (bless them with kane-cli context review; a later reconcile attaches)`,"note.sources_failed":({failed:e,total:t,sources:n})=>`${e} of ${t} source(s) failed \u2014 re-run kane-cli context extract to retry (${n})`,"note.already_designed":({use_case:e,version:t})=>`'${e}' is already designed @ v${t} \u2014 current; use --force to redesign`,"note.design_stale":({use_case:e,designed:t,current:n})=>`'${e}' was designed @ ${t} \u2014 the use-case is now @ v${n} (STALE); use --force to redesign`,"note.view_design":({use_case:e})=>`view the existing design: kane-cli context view ${e}`,"note.evolve_first":({use_case:e})=>`refresh it first: kane-cli maintain evolve ${e}`,"note.nothing_executed":()=>"nothing executed \u2014 list use-cases: kane-cli context list","note.tests_await_approval_command":({tests:e,criteria:t,criterion:n})=>{let i=e===1?"1 test checks":`${e} tests check`;return t===1&&n!==null?`note: ${i} a criterion not approved yet; to approve it, run:
2
+ import{a as d,e as l}from"./chunk-HYJVYYAZ.js";var h=e=>`'${e.replace(/'/g,"'\\''")}'`,u=e=>e!==void 0?` --mode ${e}`:"",s=({verb:e,sid:t,mode:n})=>e==="design"?`kane-cli design tests --resume ${t}${u(n)}`:`kane-cli context extract --resume ${t}${u(n)}`,g=({ref:e,because:t,answers:n})=>`kane-cli maintain evolve ${e??"--from-stale"}${t?` --because ${h(t)}`:""} --mode agent`+n.map(i=>` --answer ${i.id}=${i.choice==="proceed"?1:2}`).join(""),r=e=>`kane-cli context extract --resume ${e}`,$=e=>/^[\w@%+=:,./-]+$/.test(e)?e:h(e),a=e=>e?`to review its source's change, run: ${e}`:"review its source's change with kane-cli maintain reconcile first",o="re-run kane-cli maintain reconcile to re-stage",c=e=>`retire it first (kane-cli context retire ${e}) or ingest under a different id with --as`,_=d({commands:{"next.resume_session":s,"next.resume_with_message":e=>`${s(e)} --message "<your words>"`,"next.resume_child":({sid:e})=>`kane-cli design tests --resume ${e}`,"next.design_use_case":({use_case:e,force:t})=>`kane-cli design tests --use-case ${e}${t?" --force":""}`,"next.review_use_case":({use_case:e})=>`kane-cli context review --approve ${e}`,"next.design_unreviewed":({use_case:e})=>`kane-cli design tests --use-case ${e} --mode agent --allow-unreviewed`,"next.view_design":({use_case:e})=>`kane-cli context view ${e}`,"next.evolve_design":({use_case:e})=>`kane-cli maintain evolve ${e}`,"next.redesign":({use_case:e})=>`kane-cli design tests --use-case ${e} --force --mode agent`,"next.design_phase":({use_case:e,phase:t,agent_mode:n})=>`kane-cli design tests --use-case ${e} --phase ${t}${n?" --mode agent":""}`,"next.answer_evolve":g,"next.abandon_session":({sid:e})=>`kane-cli context sessions clean ${e}`,"next.review_held_changeset":()=>"kane-cli maintain reconcile --apply","next.show_session":({sid:e})=>`kane-cli context sessions show ${e}`,"next.review_source":({source_id:e,from:t,agent_mode:n})=>t===null?null:`kane-cli maintain reconcile --from ${$(t)}${/^https?:\/\//.test(t)?"":` --source-id ${e}`}${n?" --mode agent":""}`},texts:{...l,"note.paused":e=>e.verb==="design"?`paused \u2014 resume with: ${s(e)}`:`paused: session ${e.sid} saved \u2014 resume with: ${s(e)}`,"note.crashed":e=>`agent crashed \u2014 session ${e.sid} is resumable at checkpoint seq ${e.seq} (at most the in-flight turn lost); resume with: ${s(e)}`,"note.model_unavailable_kept":e=>`the model service did not answer (${e.detail}) \u2014 session ${e.sid} is kept; resume with: ${s(e)}`,"note.model_retry":({seconds:e})=>`the model service is not answering; trying again in ${e}s`,"note.already_extracted":({source_id:e})=>`${e} already extracted \u2014 skipped (--force re-runs it)`,"note.conversation_source_skipped":({source_id:e})=>`skipped ${e} \u2014 conversation source; extract it explicitly with --source ${e}`,"note.reconcile_plan_pending":({source_id:e,pending:t,path:n})=>`note: a reconcile plan for ${e} is pending (${t} item(s)) \u2014 resume with \`kane-cli maintain reconcile --apply ${n}\``,"note.nothing_to_extract":({sources:e,count:t})=>`extract: nothing to do \u2014 ${e} ${t===1?"is":"are all"} already extracted at the current snapshot (--force to re-run)`,"note.only_conversation_sources":()=>"extract: nothing to do \u2014 only conversation sources here (extract one explicitly with --source <id>)","note.all_extracted":()=>"extract: nothing to do \u2014 every ingested source is already extracted","note.changeset_held_for_review":({held:e})=>`paused: ${e} held change(s) await your verdicts \u2014 review them in a terminal: kane-cli maintain reconcile --apply`,"note.held_for_review":({sid:e,mode:t,held:n})=>`paused: ${n} held item(s) await review \u2014 resume with: ${s({verb:"extract",sid:e,mode:t})}`,"note.session_kept":e=>`session ${e.sid} kept its last checkpoint (seq ${e.seq}, ${e.ts}) \u2014 resume with: ${s(e)}`,"note.assumed_defaults":({sid:e,count:t})=>`note: ${t} default(s) were assumed while you were away \u2014 kane-cli context sessions show ${e} lists them`,"note.landed_changed":({source_id:e})=>`note: ${e} changed after it was added \u2014 skipping its extraction this run; re-run kane-cli context extract to pick up the newer version`,"note.landed_older_queued":({source_id:e})=>`note: an older version of ${e} is already queued this run \u2014 the newly landed version is not extracted; re-run kane-cli context extract to pick it up`,"note.reingest_binary":({source_id:e,kind:t})=>`skipping ${e}: binary ${t} ingested before image support \u2014 re-ingest it (kane-cli context ingest) to extract from it`,"note.schedule_refused":()=>"this run holds items for review, so its extraction is not scheduled \u2014 kane-cli context extract runs it after the review","note.not_reached":()=>"run ended before its turn \u2014 kane-cli context extract runs it","note.nothing_committed":({source_id:e,remaining:t})=>`done \u2014 nothing committed for ${e} (no finalize before the session ended)`+(t>0?`; stopping here \u2014 ${t} remaining source(s) not extracted (re-run kane-cli context extract to continue)`:""),"note.landed_not_extracted":({count:e,sources:t})=>`note: ${e} source(s) landed this session (${t}) were not extracted \u2014 the session ended first; kane-cli context extract runs them`,"note.evidence_not_attached":({count:e})=>`note: ${e} unchanged match(es) target unreviewed (or no-longer-resolving) item(s) \u2014 evidence not attached (bless them with kane-cli context review; a later reconcile attaches)`,"note.sources_failed":({failed:e,total:t,sources:n})=>`${e} of ${t} source(s) failed \u2014 re-run kane-cli context extract to retry (${n})`,"note.already_designed":({use_case:e,version:t})=>`'${e}' is already designed @ v${t} \u2014 current; use --force to redesign`,"note.design_stale":({use_case:e,designed:t,current:n})=>`'${e}' was designed @ ${t} \u2014 the use-case is now @ v${n} (STALE); use --force to redesign`,"note.view_design":({use_case:e})=>`view the existing design: kane-cli context view ${e}`,"note.evolve_first":({use_case:e})=>`refresh it first: kane-cli maintain evolve ${e}`,"note.nothing_executed":()=>"nothing executed \u2014 list use-cases: kane-cli context list","note.tests_await_approval_command":({tests:e,criteria:t,criterion:n})=>{let i=e===1?"1 test checks":`${e} tests check`;return t===1&&n!==null?`note: ${i} a criterion not approved yet; to approve it, run:
3
3
  kane-cli context review --approve ${n}`:`note: ${i} criteria not approved yet; to approve them, run:
4
4
  kane-cli context review`},"note.links_await_approval":({count:e})=>`warning: ${e} test link(s) refer to items still awaiting approval \u2014 saved anyway; review and approve those items in chat or via kane-cli context review`,"note.no_design_skipped":({use_case:e})=>`note: ${e} has no design output \u2014 nothing to evolve; run kane-cli design tests --use-case ${e} first`,"note.no_design":({use_case:e})=>`nothing to evolve \u2014 run kane-cli design tests --use-case ${e} first (no design output)`,"note.design_paused":({use_case:e})=>`design session for ${e} paused \u2014 resume with \`kane-cli design tests --resume\`, then re-run evolve for the diff`,"note.nothing_changed":({ref:e})=>`nothing changed underneath ${e} \u2014 its sources and requirements are current; use --because "<reason>" to re-design anyway`,"note.source_changed_skipped":({use_case:e,review:t})=>`${e} is left out: it's out of date because its source changed \u2014 ${a(t)}`,"note.source_changed":({use_case:e,review:t})=>`${e} is out of date because its source changed, and an update can't change that \u2014 ${a(t)}`,"note.source_changed_after":({use_case:e,review:t})=>`${e} is still out of date because its source changed \u2014 ${a(t)}`,"note.checkpoint_not_saved":({error:e,chain_unverified:t})=>`warning: couldn't save the session checkpoint \u2014 ${e}; asking the agent to pause`+(t?". The store's record chain fails verification \u2014 run kane-cli context fsck to diagnose.":""),"note.held_no_event_id":({sid:e})=>`this held row has no durable event id \u2014 resume the owner to drop it: ${r(e)}`,"note.held_no_provenance":({sid:e})=>`this held row carries no committable provenance \u2014 resume the owner to apply it: ${r(e)}`,"note.held_no_citable_text":({sid:e,source_id:t,source_cid:n})=>`the pinned source ${t} (${n.slice(0,19)}) has no citable text to verify this held row against \u2014 resume the owner: ${r(e)}`,"note.held_unverified":({sid:e,errors:t})=>`held provenance does not verify against the pinned source (${t}) \u2014 resume the owner: ${r(e)}`,"note.controller_unreachable":({base:e,error:t})=>`error: cannot reach the controller at ${e} (${t})
5
5
  hint: check your network connection and login (kane-cli whoami)`,"note.assurance_unsupported":()=>"error: this environment does not support assurance sessions yet (404) \u2014 update kane-cli, or contact support if the problem persists","note.credentials_rejected":({env:e})=>`error: your credentials were rejected (401) \u2014 run kane-cli login (active environment: ${e})`,"note.key_recycled":({source_id:e,what:t})=>`source '${e}' was ingested from a different ${t} that used this key \u2014 the key was recycled; ${c(e)}`,"note.kind_taken":({source_id:e,backing:t,kind:n})=>`source '${e}' is already backed by ${t}, not ${n} \u2014 ${c(e)}`,"note.site_moved":({source_id:e,previous:t,site:n})=>`source '${e}' was ingested from ${t}, but this read serves ${n} \u2014 ${c(e)}`,"note.web_url_changed":({source_id:e,previous:t})=>`source '${e}' was ingested from ${t} \u2014 re-run on a TTY to adopt the new URL as its next version, or ingest under a different id with --as`,"note.web_id_taken":({url:e})=>`skipped ${e} \u2014 ingest under a different id with --as to keep both pages`,"note.web_login":()=>"your credentials were rejected \u2014 run `kane-cli login` and retry","note.web_projection_unknown":({kind:e})=>`unknown web projection kind '${e}' \u2014 update kane-cli to read this source`,LIS_AUTH:()=>"credentials rejected \u2014 run `kane-cli login` and retry",MULTI_SOURCE_RESUME:({sid:e,sources:t})=>`error: session ${e} spans ${t} sources \u2014 multi-source resume isn't supported yet; committed work is preserved (re-run kane-cli context extract for anything remaining)`,CHANGE_BASIS_MOVED:({source_id:e,sid:t})=>`error: ${e} moved while this reconcile extraction was paused \u2014 its recorded change context no longer matches; re-run kane-cli maintain reconcile against the current file (session ${t} is defunct and can be ignored)`,PROPOSAL_UNREADABLE:({proposal:e})=>`proposal ${e} is unreadable \u2014 re-run maintain reconcile`,SOURCE_UNRESOLVED:({source_id:e})=>`the source ${e} no longer resolves \u2014 cannot verify this changeset is current; re-run maintain reconcile`,SOURCE_MOVED:({source_id:e})=>`the source ${e} moved again while this review was open \u2014 re-run maintain reconcile to refresh the changeset`,ARCHIVE_UNRESOLVED:({use_case:e})=>`its archive op no longer resolves to ${e} \u2014 re-run maintain reconcile`,POSTURE_IN_CHAT:({sid:e})=>`error: session ${e} is a held reconcile review \u2014 resumed in the chat its changes would commit without verdicts; review its cards with kane-cli maintain reconcile --apply`,SOURCE_MISSING:({sid:e,sources:t})=>`error: resumed session's paused source (${t}) is no longer in the corpus \u2014 restore/re-ingest it and re-run --resume ${e}, or discard with: kane-cli context sessions clean ${e}`,BLOB_MISSING:({source_id:e})=>`error: ${e}: its stored content is missing \u2014 re-ingest the file (kane-cli context ingest <file>) [BLOB_MISSING]`,"AGENT_FAILED.invalid_proposal":({source_id:e})=>`error: the agent could not produce a valid proposal for ${e} \u2014 re-run kane-cli context extract to retry`,UC_UNREVIEWED:({use_case:e})=>`${e} is unreviewed \u2014 approve it first, or pass --allow-unreviewed`,"UC_UNREVIEWED.merge_target":({temp_ref:e,target:t})=>`${e}: merge target ${t} is unreviewed (derived) \u2014 bless it first (kane-cli context review) and re-propose the merge`,UC_HELD:({use_case:e,owner_sid:t,stopped:n})=>`design: ${e} is being designed by another session`+(n?` \u2014 that session looks stopped; resume it with kane-cli design tests --resume ${t??"<session>"}`:"")+" \u2014 pick another use-case (kane-cli design tests) or wait for it to finish",GENERATION_LIVE:({use_case:e,gen:t})=>`${e} already has a live design generation (gen ${t}) \u2014 pass --force with --because to supersede it`,MESSAGE_TOO_LARGE:({bytes:e,max:t})=>`error: the opening statement is ${e} bytes and the agent takes at most ${t} per message (it would drop it silently) \u2014 pass a shorter --because (it replaces the generated stale reason)`,REASON_TOO_LARGE:()=>"nothing was started: that reason is too long; run it again with a sentence or two",SESSION_V1:({sid:e})=>`session ${e} predates durable checkpoints \u2014 this build cannot resume it; abandon it with kane-cli context sessions clean ${e} and start a fresh run (committed work is untouched)`,WRONG_VERB:({sid:e,verb:t})=>`error: session ${e} is a ${t} session \u2014 resume it with ${s({verb:t,sid:e})}`,"HELD_CITES_STALE.moved":()=>`the source moved after this plan staged \u2014 its quotes no longer verify against the current head; ${o}`,"HELD_CITES_STALE.predates_images":({where:e,anchor:t})=>`${e}: this plan predates image-part staging \u2014 ${t} cannot be verified against the version it staged under; ${o}`,"HELD_CITES_STALE.no_image":({where:e,anchor:t})=>`${e}: ${t} names no decodable image of the staged version \u2014 ${o}`,"HELD_CITES_STALE.image_moved":({where:e,anchor:t,gone:n})=>`${e}: the image behind ${t} is ${n?"no longer in":"ambiguous in"} the current head \u2014 ${o}`}});export{_ as a};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as m}from"./chunk-HCBYKLMW.js";import{a as o,b as i}from"./chunk-33DWJV67.js";import{y as e}from"./chunk-D36V5OX6.js";import{e as d}from"./chunk-UR6MHSHU.js";var r=d(m(),1),s={default:e.muted,error:e.red,success:e.green,info:e.orange,warning:e.orange};function h({title:t,titleColor:a,borderColor:l,variant:n="default",children:c,width:u,paddingX:x=2,paddingY:g=0,marginBottom:f=0}){let p=l??s[n],B=a??(n==="default"?e.orange:s[n]);return(0,r.jsxs)(o,{flexDirection:"column",marginBottom:f,children:[t&&(0,r.jsx)(o,{marginBottom:0,children:(0,r.jsxs)(i,{color:B,bold:!0,children:[" ",t]})}),(0,r.jsx)(o,{borderStyle:"round",borderColor:p,flexDirection:"column",paddingX:x,paddingY:g,width:u,children:c})]})}function k({label:t,value:a,labelColor:l=e.dim,valueColor:n,labelWidth:c=14}){return(0,r.jsxs)(o,{children:[(0,r.jsx)(o,{width:c,flexShrink:0,children:(0,r.jsx)(i,{color:l,children:t})}),(0,r.jsx)(o,{flexShrink:1,children:(0,r.jsx)(i,{color:n,wrap:"wrap",children:a})})]})}function I({label:t}){return(0,r.jsx)(o,{marginTop:1,marginBottom:0,children:(0,r.jsx)(i,{bold:!0,children:t})})}export{h as a,k as b,I as c};
2
+ import{a as m}from"./chunk-HCBYKLMW.js";import{a as o,b as i}from"./chunk-33DWJV67.js";import{z as e}from"./chunk-FAMQ4DHU.js";import{e as d}from"./chunk-UR6MHSHU.js";var r=d(m(),1),s={default:e.muted,error:e.red,success:e.green,info:e.orange,warning:e.orange};function h({title:t,titleColor:a,borderColor:l,variant:n="default",children:c,width:u,paddingX:x=2,paddingY:g=0,marginBottom:f=0}){let p=l??s[n],B=a??(n==="default"?e.orange:s[n]);return(0,r.jsxs)(o,{flexDirection:"column",marginBottom:f,children:[t&&(0,r.jsx)(o,{marginBottom:0,children:(0,r.jsxs)(i,{color:B,bold:!0,children:[" ",t]})}),(0,r.jsx)(o,{borderStyle:"round",borderColor:p,flexDirection:"column",paddingX:x,paddingY:g,width:u,children:c})]})}function k({label:t,value:a,labelColor:l=e.dim,valueColor:n,labelWidth:c=14}){return(0,r.jsxs)(o,{children:[(0,r.jsx)(o,{width:c,flexShrink:0,children:(0,r.jsx)(i,{color:l,children:t})}),(0,r.jsx)(o,{flexShrink:1,children:(0,r.jsx)(i,{color:n,wrap:"wrap",children:a})})]})}function I({label:t}){return(0,r.jsx)(o,{marginTop:1,marginBottom:0,children:(0,r.jsx)(i,{bold:!0,children:t})})}export{h as a,k as b,I as c};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as l}from"./chunk-FCD3NYOM.js";import{a as c}from"./chunk-4QTH7VYE.js";import{a}from"./chunk-RZ4F3BHX.js";var h=class{constructor(e,t,r,s){this.controllerBaseUrl=e;this.getOAuthToken=t;this.directBasicAuth=r;this.log=s}_cached=null;_revoked=!1;_lastError=null;revoke(){this._revoked=!0,this._cached=null}prime(e){this._revoked||(this._cached=e)}get revoked(){return this._revoked}get cached(){return this._cached}get lastError(){return this._lastError}async resolve(e=!1){if(this._cached&&!e)return this._cached;try{let t;if(this.directBasicAuth)t=new l(this.controllerBaseUrl,{username:this.directBasicAuth.username,accessKey:this.directBasicAuth.access_key});else{let s=await this.getOAuthToken();if(!s)return null;t=new l(this.controllerBaseUrl,s)}let r=await t.getTmsCredentials();this.directBasicAuth&&!r.access_key&&(r.access_key=this.directBasicAuth.access_key),this._cached=r,this._lastError=null;try{let[{refreshIdentitySnapshot:s},{telemetryEnvName:n}]=await Promise.all([import("./identity-HL5CJJXR.js"),import("./bootstrap-6ACT4ALI.js")]);await s(n(),r)}catch{}return this.log?.("info","AUTH_RESOLVE_OK","Auth resolved",{username:r.username,org_id:r.org_id,user_id:r.user_id}),r}catch(t){return this._lastError=t instanceof Error?t:new Error(String(t)),this.log?.("warn","AUTH_RESOLVE_FAILED","Auth resolve failed",{error:this._lastError.message}),null}}async fetch(e,t={}){if(this._revoked)throw new Error("Resolver has been revoked \u2014 identity changed");let r=await this.resolve();if(!r)throw new Error("Not authenticated \u2014 no credentials resolved");let s=i=>({...t,headers:{...t.headers,Authorization:c(i.username,i.access_key)}}),n=await a(e,s(r));if(n.status===401){if(this._revoked)throw new Error("Resolver has been revoked \u2014 identity changed");this.log?.("warn","AUTH_RESOLVE_401","Got 401, re-resolving",{url:e});let i=await this.resolve(!0);if(!i)throw new Error("Re-authentication failed after 401");return a(e,s(i))}return n}};function _(o){if(!o)return"network";let e=/failed:\s*(\d{3})\b/.exec(o.message)?.[1];return e==="401"||e==="403"?"auth":e?"server":"network"}export{h as a,_ as b};
2
+ import{a as l}from"./chunk-FCD3NYOM.js";import{a as c}from"./chunk-4QTH7VYE.js";import{a}from"./chunk-RZ4F3BHX.js";var h=class{constructor(e,t,r,s){this.controllerBaseUrl=e;this.getOAuthToken=t;this.directBasicAuth=r;this.log=s}_cached=null;_revoked=!1;_lastError=null;revoke(){this._revoked=!0,this._cached=null}prime(e){this._revoked||(this._cached=e)}get revoked(){return this._revoked}get cached(){return this._cached}get lastError(){return this._lastError}async resolve(e=!1){if(this._cached&&!e)return this._cached;try{let t;if(this.directBasicAuth)t=new l(this.controllerBaseUrl,{username:this.directBasicAuth.username,accessKey:this.directBasicAuth.access_key});else{let s=await this.getOAuthToken();if(!s)return null;t=new l(this.controllerBaseUrl,s)}let r=await t.getTmsCredentials();this.directBasicAuth&&!r.access_key&&(r.access_key=this.directBasicAuth.access_key),this._cached=r,this._lastError=null;try{let[{refreshIdentitySnapshot:s},{telemetryEnvName:n}]=await Promise.all([import("./identity-HL5CJJXR.js"),import("./bootstrap-JEVSVPQ2.js")]);await s(n(),r)}catch{}return this.log?.("info","AUTH_RESOLVE_OK","Auth resolved",{username:r.username,org_id:r.org_id,user_id:r.user_id}),r}catch(t){return this._lastError=t instanceof Error?t:new Error(String(t)),this.log?.("warn","AUTH_RESOLVE_FAILED","Auth resolve failed",{error:this._lastError.message}),null}}async fetch(e,t={}){if(this._revoked)throw new Error("Resolver has been revoked \u2014 identity changed");let r=await this.resolve();if(!r)throw new Error("Not authenticated \u2014 no credentials resolved");let s=i=>({...t,headers:{...t.headers,Authorization:c(i.username,i.access_key)}}),n=await a(e,s(r));if(n.status===401){if(this._revoked)throw new Error("Resolver has been revoked \u2014 identity changed");this.log?.("warn","AUTH_RESOLVE_401","Got 401, re-resolving",{url:e});let i=await this.resolve(!0);if(!i)throw new Error("Re-authentication failed after 401");return a(e,s(i))}return n}};function _(o){if(!o)return"network";let e=/failed:\s*(\d{3})\b/.exec(o.message)?.[1];return e==="401"||e==="403"?"auth":e?"server":"network"}export{h as a,_ as b};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as h,c as j}from"./chunk-VLDCHFXF.js";import{f as m,g as y}from"./chunk-KU3YHPWZ.js";import{q as H}from"./chunk-PUVMC4PX.js";function E(e,t){let n=/^(.*?)(\d+)$/.exec(e),r=/^(.*?)(\d+)$/.exec(t);return n&&r&&n[1]===r[1]?Number(n[2])-Number(r[2]):e<t?-1:e>t?1:0}var R=(e,t)=>e.nameOf.get(t)??t,k=(e,t)=>!e.superseded.has(t);function de(e,t,n=r=>k(e,r)){return e.byLabel(m.SCENARIO).filter(({cid:r})=>n(r)).filter(({cid:r})=>e.edgesFrom(r).some(i=>i.type===y.BELONGS_TO&&e.tipOf(i.dst)===t)).map(({cid:r})=>r)}function ue(e,t,n=R){let r=e.tipOf(t),i=e.getNode(t)?.content??{},d=e.derivesInto(r).filter(o=>!e.superseded.has(o.ecid)),a=[...new Set(d.map(o=>String(o.props?.source_id??"")).filter(Boolean))].sort(),f=a.map(o=>{let p=e.heads.get(o);if(typeof p!="string")return{id:o};let l=e.getNode(p)?.content.blob;return{id:o,media_type:e.mediaOf(p).media_type,...typeof l=="string"?{cid:l}:{}}}),c=d[0],x=new Map;for(let o of d)o.props?.source_id&&o.props?.source_cid&&x.set(String(o.props.source_id),String(o.props.source_cid));let S=a.filter(o=>{let p=e.heads.get(o),l=x.get(o);return p!=null&&l!==void 0&&p!==l}).sort(),b=e.edgesFrom(t).filter(o=>o.type===y.DEPENDS_ON&&!e.superseded.has(o.ecid)).map(o=>q(e,o.dst,n)).filter(o=>o!==null).sort();return{id:n(e,t),title:String(i.title??""),...i.description||i.summary?{description:String(i.description??i.summary)}:{},...Array.isArray(i.actors)&&i.actors.length?{actors:i.actors.map(String)}:{},...i.value?{value:String(i.value)}:{},risk:String(i.risk??""),status:e.trust.get(t)==="trusted"?"approved":"draft",sources:f,...S.length?{stale_sources:S}:{},...b.length?{depends_on:b}:{},...c?{provenance:{derived_from:`${String(c.props?.source_id??"")}#${String(c.props?.anchor??"")}`}}:{}}}function fe(e,t,n=i=>k(e,i),r=R){let i=e.getNode(t)?.content??{},d=e.edgesFrom(t).filter(a=>a.type===y.EXERCISES&&!e.superseded.has(a.ecid)&&n(e.tipOf(a.dst))).map(a=>r(e,e.tipOf(a.dst))).sort();return{id:r(e,t),case_type:String(i.case_type??""),intent:String(i.intent??""),exercises:d}}function pe(e){if(!e.kind&&!e.expected_answer)return{};let t=e.expected_answer??{};return{expected_answer:{...e.kind?{kind:String(e.kind)}:{},statement:String(e.text??""),...t.operator!==void 0?{operator:t.operator}:{},...t.operand!==void 0?{operand:t.operand}:{}}}}function L(e,t,n,r){return t?.find(i=>i.ac_cid&&n?e.tipOf(i.ac_cid)===e.tipOf(n):i.ac_ref===r)?.verdict}function le(e){return e.byLabel(m.GAP).filter(({cid:t})=>k(e,t)&&e.trust.get(t)!=="archived").map(({cid:t,content:n})=>({ref:R(e,t),kind:String(n.kind??""),...n.risk?{risk:String(n.risk)}:{},...n.question?{question:B(n.question)}:{}})).sort((t,n)=>t.ref<n.ref?-1:1)}function B(e){if(typeof e=="string")return e;let t=e?.header;return typeof t=="string"?t:""}function q(e,t,n=R){let r=e.tipOf(t);return e.nodeLabel.get(r)!==m.USECASE||!k(e,r)?null:n(e,r)}var A=Object.freeze({high:1.25,med:1,low:.75,unknown:1}),be=Object.freeze({proven:"proven",partial:"partial",failing:"failing",not_run:"not run",not_designed:"not designed",no_criteria:"no criteria"});function ve(e){return e.usecases.total-e.usecases.not_designed-e.usecases.no_criteria}var we=(e,t)=>{let n=e.getNode(t)?.content;return typeof n?.test_md_blob=="string"&&n.test_md_blob!==""?H(e,n.test_md_blob):typeof n?.definitionId=="string"?n.definitionId:null};function he(e){return t=>e.execHistory(t).filter(n=>!n.drift_flag&&e.tipOf(n.about)===n.about)}function z(e){let t=[],n=0;for(let{cid:r}of e.byLabel(m.USECASE))h(e,r)&&(e.stale(r)==="orphaned"?n++:t.push(r));return{inScope:t,orphaned:n}}function K(e,t){let n=new Map([...t].map(r=>[r,[]]));for(let{cid:r}of e.byLabel(m.AC)){if(!h(e,r))continue;let i=j(e,r);i!==null&&n.get(i)?.push(r)}return n}function J(e){return e==="high"||e==="med"||e==="low"?A[e]:A.unknown}var I=(e,t)=>e.displayNameOf(t)??t;function X(e,t){let n=new Set;for(let r of e.edgesInto(t)){if(r.type!==y.VERIFIES||e.superseded.has(r.ecid))continue;let i=e.tipOf(r.src);h(e,i)&&n.add(i)}return[...n]}function Y(e,t,n,r,i){let d=I(e,n),a=[];for(let f of r)for(let c of t(f))i!==void 0&&!i.has(c.execution_id)||a.push({verdict:String(L(e,c.per_ac,n,d)??c.verdict),at:String(c.started_at),executionId:String(c.execution_id),manual:c.manual===!0,fact:c});return a}var P={failed:3,broken:2,skipped:1,passed:0};function Q(e,t){if(e.at!==t.at)return e.at>t.at;let n=P[e.verdict]??0,r=P[t.verdict]??0;return n!==r?n>r:e.executionId>t.executionId}function $(e){let t;for(let n of e)(t===void 0||Q(n,t))&&(t=n);return t}function Z(e,t){let n=new Map;for(let i of e.derivesInto(t)){if(e.superseded.has(i.ecid))continue;let d=i.props?.source_id,a=i.props?.source_cid;typeof d=="string"&&typeof a=="string"&&n.set(d,a)}let r=[];for(let[i,d]of n){let a=e.heads.get(i);a==null||a===d||e.convChains.get(i)?.chain.includes(d)||r.push(i)}return r}function ee(e){let t=[];for(let[n,r]of e.heads){if(r===null||e.convChains.has(n))continue;let i=e.extractionCompleteness.get(n);(!i||i.completeness!=="complete"||i.source_cid!==r)&&t.push(n)}return t.sort()}function te(e){return e.length===0?"no_criteria":e.some(t=>t!=="not_designed")?e.every(t=>t==="proven")?"proven":e.includes("failing")?"failing":e.includes("proven")?"partial":"not_run":"not_designed"}function Re(e){let{graph:t,runs:n,thisRun:r}=e,{inScope:i,orphaned:d}=z(t),a=K(t,new Set(i)),f={},c=[],x=new Set,S=!1;for(let s of i){let u=I(t,s),N=t.getNode(s)?.content??{},G=String(N.risk??""),_=[],D=new Set,F=!1;for(let g of a.get(s)??[]){let W=I(t,g),T=X(t,g),C=Y(t,n,g,T,r),v=$(C.filter(w=>w.verdict==="passed"||w.verdict==="failed")),V=T.length===0?"not_designed":v===void 0?"not_run":v.verdict==="passed"?"proven":"failing",O=r===void 0?void 0:$(C);v&&(S=!0),O&&(F=!0);for(let w of C)w.manual&&D.add(w.executionId);_.push(V),f[W]={state:V,uc:u,...v?{deciding_run:v.executionId}:{},...O?{this_run:O.verdict}:{}}}let U=Z(t,s);for(let g of U)x.add(g);let M=_.filter(g=>g==="proven").length;c.push({id:u,title:String(N.title??""),risk:G,weight:J(G),state:te(_),pct:_.length===0?0:M/_.length*100,criteria:_.length,proven:M,manual_runs:D.size,stale:U.length>0,...F?{this_run:!0}:{}})}c.sort((s,u)=>E(s.id,u.id));let b=c.reduce((s,u)=>s+u.weight,0),o={total:c.length,proven:0,partial:0,failing:0,not_run:0,not_designed:0,no_criteria:0};for(let s of c)o[s.state]++;let p=Object.keys(f).sort(E),l=s=>f[s].this_run==="passed"||f[s].this_run==="failed"?f[s].this_run:void 0;return{coverage_version:2,scope:r===void 0?"project":"run",config:{rule:"newest_counted_verdict",weighting:e.weighting??"risk",weights:A},pct:b===0?0:c.reduce((s,u)=>s+u.weight*u.pct,0)/b,...r===void 0&&!S?{note:"nothing_run_yet"}:{},usecases:o,criteria:{total:c.reduce((s,u)=>s+u.criteria,0),proven:c.reduce((s,u)=>s+u.proven,0)},perUc:c,perAc:f,flags:{stale_sources:x.size,sources_not_fully_extracted:ee(t),orphaned_usecases:d},...r===void 0?{}:{this_run:{usecases:c.filter(s=>s.this_run).map(s=>s.id),criteria_passed:p.filter(s=>l(s)==="passed"),criteria_failed:p.filter(s=>l(s)==="failed")}}}}export{E as a,de as b,ue as c,fe as d,pe as e,le as f,A as g,be as h,ve as i,we as j,he as k,z as l,K as m,I as n,X as o,Y as p,$ as q,Re as r};
2
+ import{a as h,c as j}from"./chunk-FOLUB336.js";import{q as H}from"./chunk-7V34ZMMS.js";import{f as m,g as y}from"./chunk-KU3YHPWZ.js";function E(e,t){let n=/^(.*?)(\d+)$/.exec(e),r=/^(.*?)(\d+)$/.exec(t);return n&&r&&n[1]===r[1]?Number(n[2])-Number(r[2]):e<t?-1:e>t?1:0}var R=(e,t)=>e.nameOf.get(t)??t,k=(e,t)=>!e.superseded.has(t);function de(e,t,n=r=>k(e,r)){return e.byLabel(m.SCENARIO).filter(({cid:r})=>n(r)).filter(({cid:r})=>e.edgesFrom(r).some(i=>i.type===y.BELONGS_TO&&e.tipOf(i.dst)===t)).map(({cid:r})=>r)}function ue(e,t,n=R){let r=e.tipOf(t),i=e.getNode(t)?.content??{},d=e.derivesInto(r).filter(o=>!e.superseded.has(o.ecid)),a=[...new Set(d.map(o=>String(o.props?.source_id??"")).filter(Boolean))].sort(),f=a.map(o=>{let p=e.heads.get(o);if(typeof p!="string")return{id:o};let l=e.getNode(p)?.content.blob;return{id:o,media_type:e.mediaOf(p).media_type,...typeof l=="string"?{cid:l}:{}}}),c=d[0],x=new Map;for(let o of d)o.props?.source_id&&o.props?.source_cid&&x.set(String(o.props.source_id),String(o.props.source_cid));let S=a.filter(o=>{let p=e.heads.get(o),l=x.get(o);return p!=null&&l!==void 0&&p!==l}).sort(),b=e.edgesFrom(t).filter(o=>o.type===y.DEPENDS_ON&&!e.superseded.has(o.ecid)).map(o=>q(e,o.dst,n)).filter(o=>o!==null).sort();return{id:n(e,t),title:String(i.title??""),...i.description||i.summary?{description:String(i.description??i.summary)}:{},...Array.isArray(i.actors)&&i.actors.length?{actors:i.actors.map(String)}:{},...i.value?{value:String(i.value)}:{},risk:String(i.risk??""),status:e.trust.get(t)==="trusted"?"approved":"draft",sources:f,...S.length?{stale_sources:S}:{},...b.length?{depends_on:b}:{},...c?{provenance:{derived_from:`${String(c.props?.source_id??"")}#${String(c.props?.anchor??"")}`}}:{}}}function fe(e,t,n=i=>k(e,i),r=R){let i=e.getNode(t)?.content??{},d=e.edgesFrom(t).filter(a=>a.type===y.EXERCISES&&!e.superseded.has(a.ecid)&&n(e.tipOf(a.dst))).map(a=>r(e,e.tipOf(a.dst))).sort();return{id:r(e,t),case_type:String(i.case_type??""),intent:String(i.intent??""),exercises:d}}function pe(e){if(!e.kind&&!e.expected_answer)return{};let t=e.expected_answer??{};return{expected_answer:{...e.kind?{kind:String(e.kind)}:{},statement:String(e.text??""),...t.operator!==void 0?{operator:t.operator}:{},...t.operand!==void 0?{operand:t.operand}:{}}}}function L(e,t,n,r){return t?.find(i=>i.ac_cid&&n?e.tipOf(i.ac_cid)===e.tipOf(n):i.ac_ref===r)?.verdict}function le(e){return e.byLabel(m.GAP).filter(({cid:t})=>k(e,t)&&e.trust.get(t)!=="archived").map(({cid:t,content:n})=>({ref:R(e,t),kind:String(n.kind??""),...n.risk?{risk:String(n.risk)}:{},...n.question?{question:B(n.question)}:{}})).sort((t,n)=>t.ref<n.ref?-1:1)}function B(e){if(typeof e=="string")return e;let t=e?.header;return typeof t=="string"?t:""}function q(e,t,n=R){let r=e.tipOf(t);return e.nodeLabel.get(r)!==m.USECASE||!k(e,r)?null:n(e,r)}var A=Object.freeze({high:1.25,med:1,low:.75,unknown:1}),be=Object.freeze({proven:"proven",partial:"partial",failing:"failing",not_run:"not run",not_designed:"not designed",no_criteria:"no criteria"});function ve(e){return e.usecases.total-e.usecases.not_designed-e.usecases.no_criteria}var we=(e,t)=>{let n=e.getNode(t)?.content;return typeof n?.test_md_blob=="string"&&n.test_md_blob!==""?H(e,n.test_md_blob):typeof n?.definitionId=="string"?n.definitionId:null};function he(e){return t=>e.execHistory(t).filter(n=>!n.drift_flag&&e.tipOf(n.about)===n.about)}function z(e){let t=[],n=0;for(let{cid:r}of e.byLabel(m.USECASE))h(e,r)&&(e.stale(r)==="orphaned"?n++:t.push(r));return{inScope:t,orphaned:n}}function K(e,t){let n=new Map([...t].map(r=>[r,[]]));for(let{cid:r}of e.byLabel(m.AC)){if(!h(e,r))continue;let i=j(e,r);i!==null&&n.get(i)?.push(r)}return n}function J(e){return e==="high"||e==="med"||e==="low"?A[e]:A.unknown}var I=(e,t)=>e.displayNameOf(t)??t;function X(e,t){let n=new Set;for(let r of e.edgesInto(t)){if(r.type!==y.VERIFIES||e.superseded.has(r.ecid))continue;let i=e.tipOf(r.src);h(e,i)&&n.add(i)}return[...n]}function Y(e,t,n,r,i){let d=I(e,n),a=[];for(let f of r)for(let c of t(f))i!==void 0&&!i.has(c.execution_id)||a.push({verdict:String(L(e,c.per_ac,n,d)??c.verdict),at:String(c.started_at),executionId:String(c.execution_id),manual:c.manual===!0,fact:c});return a}var P={failed:3,broken:2,skipped:1,passed:0};function Q(e,t){if(e.at!==t.at)return e.at>t.at;let n=P[e.verdict]??0,r=P[t.verdict]??0;return n!==r?n>r:e.executionId>t.executionId}function $(e){let t;for(let n of e)(t===void 0||Q(n,t))&&(t=n);return t}function Z(e,t){let n=new Map;for(let i of e.derivesInto(t)){if(e.superseded.has(i.ecid))continue;let d=i.props?.source_id,a=i.props?.source_cid;typeof d=="string"&&typeof a=="string"&&n.set(d,a)}let r=[];for(let[i,d]of n){let a=e.heads.get(i);a==null||a===d||e.convChains.get(i)?.chain.includes(d)||r.push(i)}return r}function ee(e){let t=[];for(let[n,r]of e.heads){if(r===null||e.convChains.has(n))continue;let i=e.extractionCompleteness.get(n);(!i||i.completeness!=="complete"||i.source_cid!==r)&&t.push(n)}return t.sort()}function te(e){return e.length===0?"no_criteria":e.some(t=>t!=="not_designed")?e.every(t=>t==="proven")?"proven":e.includes("failing")?"failing":e.includes("proven")?"partial":"not_run":"not_designed"}function Re(e){let{graph:t,runs:n,thisRun:r}=e,{inScope:i,orphaned:d}=z(t),a=K(t,new Set(i)),f={},c=[],x=new Set,S=!1;for(let s of i){let u=I(t,s),N=t.getNode(s)?.content??{},G=String(N.risk??""),_=[],D=new Set,F=!1;for(let g of a.get(s)??[]){let W=I(t,g),T=X(t,g),C=Y(t,n,g,T,r),v=$(C.filter(w=>w.verdict==="passed"||w.verdict==="failed")),V=T.length===0?"not_designed":v===void 0?"not_run":v.verdict==="passed"?"proven":"failing",O=r===void 0?void 0:$(C);v&&(S=!0),O&&(F=!0);for(let w of C)w.manual&&D.add(w.executionId);_.push(V),f[W]={state:V,uc:u,...v?{deciding_run:v.executionId}:{},...O?{this_run:O.verdict}:{}}}let U=Z(t,s);for(let g of U)x.add(g);let M=_.filter(g=>g==="proven").length;c.push({id:u,title:String(N.title??""),risk:G,weight:J(G),state:te(_),pct:_.length===0?0:M/_.length*100,criteria:_.length,proven:M,manual_runs:D.size,stale:U.length>0,...F?{this_run:!0}:{}})}c.sort((s,u)=>E(s.id,u.id));let b=c.reduce((s,u)=>s+u.weight,0),o={total:c.length,proven:0,partial:0,failing:0,not_run:0,not_designed:0,no_criteria:0};for(let s of c)o[s.state]++;let p=Object.keys(f).sort(E),l=s=>f[s].this_run==="passed"||f[s].this_run==="failed"?f[s].this_run:void 0;return{coverage_version:2,scope:r===void 0?"project":"run",config:{rule:"newest_counted_verdict",weighting:e.weighting??"risk",weights:A},pct:b===0?0:c.reduce((s,u)=>s+u.weight*u.pct,0)/b,...r===void 0&&!S?{note:"nothing_run_yet"}:{},usecases:o,criteria:{total:c.reduce((s,u)=>s+u.criteria,0),proven:c.reduce((s,u)=>s+u.proven,0)},perUc:c,perAc:f,flags:{stale_sources:x.size,sources_not_fully_extracted:ee(t),orphaned_usecases:d},...r===void 0?{}:{this_run:{usecases:c.filter(s=>s.this_run).map(s=>s.id),criteria_passed:p.filter(s=>l(s)==="passed"),criteria_failed:p.filter(s=>l(s)==="failed")}}}}export{E as a,de as b,ue as c,fe as d,pe as e,le as f,A as g,be as h,ve as i,we as j,he as k,z as l,K as m,I as n,X as o,Y as p,$ as q,Re as r};