@testmuai/kane-cli 0.7.1 → 0.8.1

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 (308) hide show
  1. package/dist/ChatSurface-U37VZDCW.js +8 -0
  2. package/dist/{ChromeProfilePicker-4CDSPBWL.js → ChromeProfilePicker-AUU7JF6F.js} +1 -1
  3. package/dist/{CliFeedbackPrompt-TLRVBA4E.js → CliFeedbackPrompt-4W74Y3UF.js} +1 -1
  4. package/dist/{CliUploadProgress-WGGFLUSF.js → CliUploadProgress-6HL7WTEX.js} +1 -1
  5. package/dist/ConfigView-6BSCZP5Y.js +2 -0
  6. package/dist/EvidenceViewOffer-62XHEEGW.js +2 -0
  7. package/dist/FolderPicker-S7U2EN2M.js +2 -0
  8. package/dist/{HelpView-FBCX32U7.js → HelpView-TU7ED43J.js} +1 -1
  9. package/dist/{InfoBox-KK2ICVS4.js → InfoBox-JLTMKVDE.js} +1 -1
  10. package/dist/{LinksBox-KKRANMR3.js → LinksBox-LREUUJDV.js} +1 -1
  11. package/dist/{ProfilesView-DGPXSAQN.js → ProfilesView-W3GX2N2E.js} +1 -1
  12. package/dist/{ProjectPicker-ESQSL4TT.js → ProjectPicker-SYQUJK2J.js} +1 -1
  13. package/dist/{SaveSessionPrompt-AQGP5W6E.js → SaveSessionPrompt-MR5NJMRP.js} +1 -1
  14. package/dist/SingleShotApp-XOKVOM7C.js +2 -0
  15. package/dist/{SummaryBox-BFZJW2KK.js → SummaryBox-UAYSVFB7.js} +1 -1
  16. package/dist/TestMdRunView-7UVSDAF4.js +2 -0
  17. package/dist/{WhoamiView-JABY3I5Q.js → WhoamiView-2YU76ASQ.js} +1 -1
  18. package/dist/adbkit-apkreader-ORZBGCJQ.js +184 -0
  19. package/dist/app-client-OEXESV4U.js +2 -0
  20. package/dist/app-download-AEEFQ63M.js +2 -0
  21. package/dist/{auth-76LVI6B5.js → auth-HET3TBRI.js} +1 -1
  22. package/dist/bind-STKXOUYI.js +12 -0
  23. package/dist/bootstrap-44YKVWWE.js +2 -0
  24. package/dist/bridge-5Z3BIB77.js +2 -0
  25. package/dist/{changelog-PSWPPOAF.js → changelog-7OWRHFHZ.js} +1 -1
  26. package/dist/chat-committer-ZWWCLJFD.js +2 -0
  27. package/dist/chat-controller-T2FAI55V.js +2 -0
  28. package/dist/{chunk-C4G7RVJ6.js → chunk-27U4PLPX.js} +1 -1
  29. package/dist/{chunk-V36ATG7A.js → chunk-2BGUUWNF.js} +2 -2
  30. package/dist/chunk-2KDGIZED.js +4 -0
  31. package/dist/chunk-2UIHS2FH.js +2 -0
  32. package/dist/chunk-2YEHV2CX.js +2 -0
  33. package/dist/{chunk-NRTHYROA.js → chunk-3LJWYRAA.js} +1 -1
  34. package/dist/chunk-3PECJD6S.js +11 -0
  35. package/dist/chunk-3POR47RC.js +8 -0
  36. package/dist/{chunk-KVQOBPAZ.js → chunk-3Q6WAK6P.js} +1 -1
  37. package/dist/chunk-4JOD47QI.js +2 -0
  38. package/dist/chunk-56PAQAX5.js +19 -0
  39. package/dist/{chunk-FCMLIK7P.js → chunk-5DBK6QNS.js} +1 -1
  40. package/dist/chunk-5DT7PIGB.js +5 -0
  41. package/dist/chunk-65ZTD5SJ.js +7 -0
  42. package/dist/chunk-6IA6QMPH.js +2 -0
  43. package/dist/{chunk-5KFS3GAZ.js → chunk-6KPPGMO2.js} +1 -1
  44. package/dist/{chunk-F6ZOJXYU.js → chunk-6O3DDOP2.js} +1 -1
  45. package/dist/chunk-6XX4LEVJ.js +2 -0
  46. package/dist/{chunk-KT6G7AF2.js → chunk-766WGMBU.js} +1 -1
  47. package/dist/chunk-7BZSCUPP.js +10 -0
  48. package/dist/{chunk-UBFKZEX3.js → chunk-7JWKHKFU.js} +2 -2
  49. package/dist/{chunk-PMHJRT3A.js → chunk-7KORP5FF.js} +1 -1
  50. package/dist/chunk-7Q6M6P4X.js +26 -0
  51. package/dist/{chunk-AM5S4KG4.js → chunk-AFPHLUQ5.js} +1 -1
  52. package/dist/chunk-AW2XUHH4.js +2 -0
  53. package/dist/chunk-BKHXPBWN.js +2 -0
  54. package/dist/chunk-BRHNRCEZ.js +3 -0
  55. package/dist/chunk-BRIEBB2U.js +2 -0
  56. package/dist/{chunk-NJPTOKW5.js → chunk-C7HSWZP6.js} +1 -1
  57. package/dist/{chunk-JEUA4UWK.js → chunk-CLGC7VEO.js} +1 -1
  58. package/dist/chunk-CTW2VQKS.js +6 -0
  59. package/dist/{chunk-L4JIMNKW.js → chunk-CUM23TLF.js} +1 -1
  60. package/dist/chunk-DBIBROYW.js +5 -0
  61. package/dist/{chunk-L7VREJTG.js → chunk-DCY6R5DP.js} +1 -1
  62. package/dist/{chunk-X3ICV5M5.js → chunk-DO5HAO3H.js} +1 -1
  63. package/dist/chunk-DPUV6OSP.js +2 -0
  64. package/dist/{chunk-M7WQM4UA.js → chunk-DUAXZYAD.js} +1 -1
  65. package/dist/{chunk-HPMS5KO6.js → chunk-DZGCXKKI.js} +3 -3
  66. package/dist/chunk-EDSZJZFG.js +4 -0
  67. package/dist/{chunk-OIYGGEUL.js → chunk-ELM6MXGJ.js} +1 -1
  68. package/dist/{chunk-R2RGSO4B.js → chunk-EWCAFKLX.js} +1 -1
  69. package/dist/chunk-EYOCNMUM.js +2 -0
  70. package/dist/{chunk-73C4PRYU.js → chunk-FEJXWJ3L.js} +1 -1
  71. package/dist/{chunk-BAL64WSI.js → chunk-FMRSMN34.js} +1 -1
  72. package/dist/chunk-FNH55WSR.js +19 -0
  73. package/dist/chunk-FQLIW3LM.js +2 -0
  74. package/dist/{chunk-JRMDGLLT.js → chunk-G7VQCS4J.js} +1 -1
  75. package/dist/chunk-GCBKDX2J.js +2 -0
  76. package/dist/{chunk-AAONIIQV.js → chunk-GFKCTYCA.js} +1 -1
  77. package/dist/chunk-GKYPNSQP.js +26 -0
  78. package/dist/chunk-GPG3FIN3.js +21 -0
  79. package/dist/chunk-GZPK6FRP.js +7 -0
  80. package/dist/{chunk-NOCIMJSN.js → chunk-HCKH44I2.js} +1 -1
  81. package/dist/chunk-HEAIJCGZ.js +2 -0
  82. package/dist/{chunk-3FN5VJMV.js → chunk-HMYMSRA4.js} +1 -1
  83. package/dist/chunk-I7TIGB7K.js +2 -0
  84. package/dist/chunk-IDX3TOPY.js +6 -0
  85. package/dist/{chunk-CVOGP253.js → chunk-IMR64OCZ.js} +1 -1
  86. package/dist/{chunk-IBNC444G.js → chunk-IOD3HQVW.js} +1 -1
  87. package/dist/chunk-IOFZSQAA.js +2 -0
  88. package/dist/chunk-IP2O264K.js +3 -0
  89. package/dist/{chunk-CSQ46PJ7.js → chunk-JJHG3BWO.js} +1 -1
  90. package/dist/{chunk-5JTUL6XL.js → chunk-JZ26R6UL.js} +1 -1
  91. package/dist/chunk-KBM3XHAM.js +2 -0
  92. package/dist/{chunk-SY3HLQMV.js → chunk-KCCSWEGA.js} +1 -1
  93. package/dist/chunk-KFSUPQAG.js +66 -0
  94. package/dist/chunk-KRKGZ2ZW.js +47 -0
  95. package/dist/chunk-KU6IXFGZ.js +9 -0
  96. package/dist/chunk-L7MXYCD7.js +2 -0
  97. package/dist/chunk-MA34UWKX.js +4 -0
  98. package/dist/chunk-MBF3FP5P.js +5 -0
  99. package/dist/chunk-MSGW4JDG.js +2 -0
  100. package/dist/chunk-MXHHMIO2.js +349 -0
  101. package/dist/chunk-N2P4MI32.js +2 -0
  102. package/dist/{chunk-CDQX6HGJ.js → chunk-NX7TM662.js} +1 -1
  103. package/dist/chunk-OMQCD3KR.js +2 -0
  104. package/dist/{chunk-QROUKGKU.js → chunk-OS4VSIHT.js} +1 -1
  105. package/dist/chunk-OTTGS2TE.js +2 -0
  106. package/dist/chunk-QGKPLOUI.js +2 -0
  107. package/dist/{chunk-JKTFTF24.js → chunk-QRZRSAZH.js} +1 -1
  108. package/dist/{chunk-WJ5HDEVH.js → chunk-QSDH5P7C.js} +1 -1
  109. package/dist/{chunk-322JEJEH.js → chunk-QW6EZC53.js} +1 -1
  110. package/dist/{chunk-2XMJ6YAE.js → chunk-R5T4RLF5.js} +1 -1
  111. package/dist/chunk-R7QAS6LZ.js +4 -0
  112. package/dist/{chunk-LR5XO2KD.js → chunk-RC52N7PC.js} +1 -1
  113. package/dist/{chunk-33QXD75Y.js → chunk-RFR4ZKIC.js} +3 -3
  114. package/dist/{chunk-3LWTUMDG.js → chunk-RLRNLIRS.js} +1 -1
  115. package/dist/{chunk-XDHZMCTA.js → chunk-SDPRO2LE.js} +2 -2
  116. package/dist/chunk-T5Y6MOLM.js +4 -0
  117. package/dist/{chunk-4OPQJ7PE.js → chunk-TFPPEOAK.js} +1 -1
  118. package/dist/chunk-TH47OOBV.js +4 -0
  119. package/dist/{chunk-XVDJ423L.js → chunk-TKGUT425.js} +1 -1
  120. package/dist/{chunk-OHRS3H7Z.js → chunk-TRJUD3XJ.js} +1 -1
  121. package/dist/chunk-TYLYFERW.js +10 -0
  122. package/dist/chunk-TZXXJWHA.js +2 -0
  123. package/dist/chunk-UD7KKHPW.js +5 -0
  124. package/dist/{chunk-APAIWBIH.js → chunk-UDIQOJEL.js} +1 -1
  125. package/dist/chunk-UV462FZR.js +2 -0
  126. package/dist/{chunk-323MLBYA.js → chunk-UXDL4XDL.js} +1 -1
  127. package/dist/chunk-V2R3LCA3.js +12 -0
  128. package/dist/chunk-VAYBKR76.js +4 -0
  129. package/dist/{chunk-AH7ZZIZY.js → chunk-VRVFPMCR.js} +1 -1
  130. package/dist/chunk-W2JFDDIB.js +2 -0
  131. package/dist/chunk-W4B5LOEX.js +4 -0
  132. package/dist/{chunk-36OC3TFE.js → chunk-W5TTF7GB.js} +2 -2
  133. package/dist/chunk-WXHQYYD5.js +2 -0
  134. package/dist/{chunk-6HEGD6H2.js → chunk-XO5ZH3ZR.js} +1 -1
  135. package/dist/chunk-XWKUZJCP.js +2 -0
  136. package/dist/{chunk-2KBD6JZX.js → chunk-YFYCCTSL.js} +1 -1
  137. package/dist/{chunk-ZM5PVRJK.js → chunk-YJELGSKJ.js} +1 -1
  138. package/dist/chunk-YRFMPIU2.js +4 -0
  139. package/dist/{chunk-2XGDWUJ5.js → chunk-ZGBSGZZM.js} +1 -1
  140. package/dist/{chunk-NBKQT7LJ.js → chunk-ZIUAOEUC.js} +1 -1
  141. package/dist/chunk-ZMNJBUAO.js +2 -0
  142. package/dist/chunk-ZVHCQMJ6.js +13 -0
  143. package/dist/committer-SWEWEYNX.js +2 -0
  144. package/dist/{config-R3GF2FZA.js → config-RS47F5SC.js} +1 -1
  145. package/dist/{controller-client-RD2YEMAH.js → controller-client-OB4WD2C4.js} +1 -1
  146. package/dist/{cover-cmd-TXICWHUU.js → cover-cmd-HDZZWJXG.js} +1 -1
  147. package/dist/{credentials-XN4ROCQ3.js → credentials-OH6AVI6N.js} +1 -1
  148. package/dist/deps-resolve-XC5S53DG.js +2 -0
  149. package/dist/descriptor-OEUZZCOK.js +2 -0
  150. package/dist/design-committer-VYT6NU3T.js +2 -0
  151. package/dist/dispatch-SE5GY3Z2.js +2 -0
  152. package/dist/doctor-FSECFZUU.js +2 -0
  153. package/dist/docx-convert-JMUMT5C4.js +2 -0
  154. package/dist/{dossier-QZV74XOS.js → dossier-KTLTGT2X.js} +1 -1
  155. package/dist/evidence-OYPHZUKI.js +2 -0
  156. package/dist/evolve-cmd-BCPNXAMV.js +2 -0
  157. package/dist/exec-P2IKJRRR.js +2 -0
  158. package/dist/exit-manager-3FVBTNYR.js +2 -0
  159. package/dist/explain-UAAQWHYR.js +2 -0
  160. package/dist/{explain-cmd-X7JZLSZZ.js → explain-cmd-3GEKR7O5.js} +1 -1
  161. package/dist/{explain-cmd-RZW6QJYM.js → explain-cmd-EX24XKD6.js} +1 -1
  162. package/dist/extract-bind-LLEASZAK.js +10 -0
  163. package/dist/extract-cmd-UZMEZMGP.js +5 -0
  164. package/dist/feeder-C3TOJPKK.js +2 -0
  165. package/dist/{gaps-cmd-BWCRLLBK.js → gaps-cmd-IVXFPFAQ.js} +1 -1
  166. package/dist/{gate-YHBPWEM5.js → gate-54BRAE7N.js} +1 -1
  167. package/dist/{generate-headless-BSTDLZZY.js → generate-headless-D3SVQ2AI.js} +3 -3
  168. package/dist/{headless-io-BL3TEAX5.js → headless-io-66RG5NN5.js} +1 -1
  169. package/dist/host-7GZPBA74.js +2 -0
  170. package/dist/identity-ADZ4PAJF.js +2 -0
  171. package/dist/index.js +85 -69
  172. package/dist/ingest-EX72IEQT.js +2 -0
  173. package/dist/ingest-cmd-EAE7N5RC.js +2 -0
  174. package/dist/{interactive-bind-43HGDF5K.js → interactive-bind-ORMN2REX.js} +7 -6
  175. package/dist/{lifecycle-cmd-D6TVTYRK.js → lifecycle-cmd-O2324GN6.js} +1 -1
  176. package/dist/{list-cmd-XCAV2FKA.js → list-cmd-N4KMA34H.js} +1 -1
  177. package/dist/list-commands-MRXL5HGS.js +2 -0
  178. package/dist/locks-cmd-CSVSWY2Y.js +2 -0
  179. package/dist/logical-ids-TEBCQJGO.js +2 -0
  180. package/dist/login-flow-QJQM3RHT.js +2 -0
  181. package/dist/maintenance-cmd-6XSVO6FO.js +2 -0
  182. package/dist/mobile-prompts-TOX35ER6.js +2 -0
  183. package/dist/pdf-convert-OZIRUADA.js +2 -0
  184. package/dist/persist-recorded-session-TLDQ5HKP.js +3 -0
  185. package/dist/phase-seed-VFHIH6FL.js +2 -0
  186. package/dist/pipeline-UOM4LNAI.js +2 -0
  187. package/dist/prepare-target-QYWIJIVQ.js +2 -0
  188. package/dist/readmodel-XOYGGQ3S.js +2 -0
  189. package/dist/reconcile-cmd-3H34KVVD.js +2 -0
  190. package/dist/reconcile-deps-XIH75ZLY.js +4 -0
  191. package/dist/reconcile-engine-UKWPG2LV.js +2 -0
  192. package/dist/{recording-banner-TALO7PUR.js → recording-banner-4M7XHVGI.js} +1 -1
  193. package/dist/records-IOZTZUZV.js +2 -0
  194. package/dist/registry-PYOTKZYZ.js +2 -0
  195. package/dist/{require-project-folder-R347LFDQ.js → require-project-folder-4UPQNEBJ.js} +1 -1
  196. package/dist/resolve-run-intent-X72V3KJA.js +7 -0
  197. package/dist/{resolver-IDCGRPFJ.js → resolver-UBOZLFFE.js} +1 -1
  198. package/dist/revert-NQ7GEVSE.js +2 -0
  199. package/dist/review-cmd-DQRKQUMG.js +4 -0
  200. package/dist/run-2COODVX2.js +2 -0
  201. package/dist/run-URPGHOQM.js +2 -0
  202. package/dist/run-channel-RGH4WIQX.js +2 -0
  203. package/dist/{run-test-md-DFNIGYB7.js → run-test-md-76ZPKXO6.js} +3 -3
  204. package/dist/session-target-UWROGOCY.js +2 -0
  205. package/dist/sessions-GIEXOCE4.js +2 -0
  206. package/dist/{sessions-cmd-AQWLL5ZN.js → sessions-cmd-ZZIZN2VB.js} +4 -4
  207. package/dist/{skill-installer-ANXTCXQV.js → skill-installer-CIS6GAYF.js} +1 -1
  208. package/dist/spawner-J67QR4QP.js +2 -0
  209. package/dist/structured-answers-5EY2AZN7.js +5 -0
  210. package/dist/tcg-generate-BDTRKY2A.js +2 -0
  211. package/dist/testmd-actions-77ELR5UU.js +2 -0
  212. package/dist/token-refresh-4BPAPXKK.js +2 -0
  213. package/dist/types-6E2HTDKJ.js +2 -0
  214. package/dist/{validate-basic-O2DP2XJL.js → validate-basic-2GVSQ2R5.js} +1 -1
  215. package/dist/verdicts-TRSTJLCL.js +2 -0
  216. package/dist/{version-check-RNR3JCQ5.js → version-check-O6PYTI4T.js} +1 -1
  217. package/dist/{view-cmd-YSEGA5PI.js → view-cmd-KPJTP4DI.js} +1 -1
  218. package/dist/walk-session-CHJXHZMO.js +2 -0
  219. package/dist/with-telemetry-CQCWLVOC.js +2 -0
  220. package/package.json +12 -6
  221. package/dist/ChatSurface-D66CACLX.js +0 -8
  222. package/dist/ConfigView-DBANTBXC.js +0 -2
  223. package/dist/EvidenceViewOffer-DNCQ3A6R.js +0 -2
  224. package/dist/FolderPicker-W7RCIFEL.js +0 -2
  225. package/dist/SingleShotApp-SMCAIKCE.js +0 -2
  226. package/dist/TestMdRunView-FMKZJ3A3.js +0 -2
  227. package/dist/bind-AACBTSAA.js +0 -12
  228. package/dist/bootstrap-CNOZ5VRB.js +0 -2
  229. package/dist/bridge-T4HL4TG7.js +0 -2
  230. package/dist/chat-committer-4BQBOKI4.js +0 -2
  231. package/dist/chat-controller-NNTMKEPG.js +0 -2
  232. package/dist/chunk-2SREGETM.js +0 -4
  233. package/dist/chunk-3STZLM5J.js +0 -4
  234. package/dist/chunk-5YPBPZUR.js +0 -2
  235. package/dist/chunk-6UJDOAYR.js +0 -26
  236. package/dist/chunk-BQHKBOSF.js +0 -11
  237. package/dist/chunk-DQ54MH7F.js +0 -13
  238. package/dist/chunk-DXV6MBTD.js +0 -8
  239. package/dist/chunk-EV3EHXEI.js +0 -4
  240. package/dist/chunk-F7WKDMX7.js +0 -47
  241. package/dist/chunk-FPFOW6BS.js +0 -2
  242. package/dist/chunk-GVIPTX6T.js +0 -6
  243. package/dist/chunk-GW5DWAXY.js +0 -2
  244. package/dist/chunk-HJERKSBK.js +0 -349
  245. package/dist/chunk-IQDWBTRJ.js +0 -3
  246. package/dist/chunk-IXVOXJP6.js +0 -6
  247. package/dist/chunk-KNDSQ4PS.js +0 -2
  248. package/dist/chunk-KRXSXQBU.js +0 -12
  249. package/dist/chunk-LQZ2BU7Q.js +0 -2
  250. package/dist/chunk-NAC7SFBE.js +0 -5
  251. package/dist/chunk-NAE7MBR2.js +0 -23
  252. package/dist/chunk-NRC2G4Y5.js +0 -5
  253. package/dist/chunk-O56PUUNL.js +0 -9
  254. package/dist/chunk-QM4S2APK.js +0 -2
  255. package/dist/chunk-RKWJG3WW.js +0 -19
  256. package/dist/chunk-RNSSM2BK.js +0 -11
  257. package/dist/chunk-SE6WNCYU.js +0 -4
  258. package/dist/chunk-SRDHPKJT.js +0 -2
  259. package/dist/chunk-SWESH2J7.js +0 -10
  260. package/dist/chunk-T63R6QT4.js +0 -4
  261. package/dist/chunk-UI7KULSI.js +0 -7
  262. package/dist/chunk-UPPEOQJQ.js +0 -3
  263. package/dist/chunk-URQUQWGW.js +0 -62
  264. package/dist/chunk-UX2B7L6K.js +0 -2
  265. package/dist/chunk-VOHQA2SP.js +0 -2
  266. package/dist/chunk-W5DOU2DV.js +0 -2
  267. package/dist/chunk-W6VD2XFO.js +0 -19
  268. package/dist/chunk-WAOCHXJ5.js +0 -2
  269. package/dist/chunk-WWNSD6FA.js +0 -6
  270. package/dist/chunk-ZLCZDAEX.js +0 -6
  271. package/dist/committer-2EJPVVCQ.js +0 -2
  272. package/dist/descriptor-KXDJ4XYD.js +0 -2
  273. package/dist/design-committer-BQUWD6AC.js +0 -2
  274. package/dist/docx-convert-ZBVQO2LG.js +0 -2
  275. package/dist/evidence-V23FPVXQ.js +0 -2
  276. package/dist/evolve-cmd-PZCPXDMR.js +0 -2
  277. package/dist/exit-manager-HNFATGSM.js +0 -2
  278. package/dist/explain-UE4IACQH.js +0 -2
  279. package/dist/extract-bind-BFY7IRL4.js +0 -10
  280. package/dist/extract-cmd-U3MGK2LP.js +0 -6
  281. package/dist/feeder-XGTFV7TZ.js +0 -2
  282. package/dist/ingest-AL6CABJT.js +0 -2
  283. package/dist/ingest-cmd-O6OWWZT4.js +0 -2
  284. package/dist/list-commands-747UTUSS.js +0 -2
  285. package/dist/locks-cmd-QAULI5LV.js +0 -2
  286. package/dist/logical-ids-4G4FAHNJ.js +0 -2
  287. package/dist/login-flow-CV76ENHV.js +0 -2
  288. package/dist/maintenance-cmd-ZRB4NTGG.js +0 -2
  289. package/dist/pdf-convert-S7VYE6AV.js +0 -2
  290. package/dist/persist-recorded-session-MDPWWUA7.js +0 -3
  291. package/dist/phase-seed-52LRE3LH.js +0 -2
  292. package/dist/pipeline-LM5JAK7F.js +0 -2
  293. package/dist/readmodel-X7L7W2BA.js +0 -2
  294. package/dist/reconcile-cmd-DGCSDML6.js +0 -2
  295. package/dist/records-5SVUXJBW.js +0 -2
  296. package/dist/revert-DXXYXJGN.js +0 -2
  297. package/dist/review-cmd-2QF5HTI7.js +0 -4
  298. package/dist/run-52UIBPXD.js +0 -2
  299. package/dist/run-VRVH4VO3.js +0 -2
  300. package/dist/sessions-BLXZVK5U.js +0 -2
  301. package/dist/spawner-AH5FTUYU.js +0 -2
  302. package/dist/structured-answers-QHFGZPSS.js +0 -5
  303. package/dist/tcg-generate-WKCBBKI5.js +0 -2
  304. package/dist/testmd-actions-RPYG6TJG.js +0 -2
  305. package/dist/token-refresh-NIDUOTRM.js +0 -2
  306. package/dist/verdicts-TJH3O5UW.js +0 -2
  307. package/dist/walk-session-HXW4OSA2.js +0 -2
  308. package/dist/with-telemetry-PNP6CAVM.js +0 -2
@@ -1,349 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{c as We}from"./chunk-IBNC444G.js";import{a as Ve}from"./chunk-KHU7C6EE.js";import{a as Ue,b as me}from"./chunk-KVQOBPAZ.js";import{a as He,b as ze}from"./chunk-5JTUL6XL.js";import{a as oe,b as Ne,e as ce,f as le,g as je,h as Ge}from"./chunk-O56PUUNL.js";import{a as Te,b as Ae,c as Ie}from"./chunk-NRC2G4Y5.js";import{a as qe,c as Le,d as Be,e as de,f as Fe}from"./chunk-2XGDWUJ5.js";import{a as Re,b as Ee,c as Ce}from"./chunk-BB2W35TW.js";import{a as Oe}from"./chunk-L2TV4G56.js";import{c as Pe}from"./chunk-5KFS3GAZ.js";import{a as De,e as $e}from"./chunk-AAONIIQV.js";import{a as Me}from"./chunk-CVOGP253.js";import{a as Se,b as ae}from"./chunk-GVIPTX6T.js";import{b as _e,c as ye,d as be,e as ie,f as ne,g as re}from"./chunk-ZPDM6FO7.js";import{a as se}from"./chunk-L5LI2JF4.js";import{a as F}from"./chunk-GW5DWAXY.js";import{f as xe}from"./chunk-M7WQM4UA.js";import{a as ve,e as we,f as ke}from"./chunk-WWNSD6FA.js";import{d as V,e as J}from"./chunk-5YPBPZUR.js";import{a as he}from"./chunk-5EOX4MEY.js";import{mkdirSync as kt,appendFileSync as xt,rmdirSync as lt}from"fs";import{randomBytes as St}from"crypto";import{dirname as dt,join as fe}from"path";function Ke(t,e){let n=[];for(let s of e??[]){let g=t.resolve(s.ref)?.tip??null;g!==s.cid&&n.push({ref:s.ref,pinned:s.cid,now:g})}return n}import{existsSync as ue,readFileSync as ge,readdirSync as ut}from"fs";import{join as Z}from"path";var Qe=`
3
- version: 1
4
- techniques:
5
- - id: eqp
6
- name: "Equivalence partitioning"
7
- applies_hint: "any constrained input"
8
- emits: [absolute, forbidden-presence]
9
- - id: bva
10
- name: "Boundary value analysis"
11
- applies_hint: "input has an ordered range or length"
12
- emits: [absolute, forbidden-presence]
13
- - id: negative
14
- name: "Negative / error"
15
- applies_hint: "any input or action that can fail"
16
- emits: [forbidden-presence]
17
- - id: state_flow
18
- name: "State / flow"
19
- applies_hint: "the AC sits in a multi-step flow"
20
- emits: [state-transition]
21
- - id: crud
22
- name: "CRUD round-trip"
23
- applies_hint: "AC touches a persisted resource"
24
- emits: [delta, presence, forbidden-presence]
25
- - id: auth
26
- name: "Auth / permission"
27
- applies_hint: "AC is behind a gate or role"
28
- emits: [forbidden-presence, presence]
29
- - id: api_contract
30
- name: "API-contract"
31
- applies_hint: "surface is REST/GraphQL"
32
- emits: [absolute]
33
- - id: concurrency
34
- name: "Concurrency / race"
35
- applies_hint: "high-risk (money / data-loss) or shared-resource AC"
36
- emits: [state-transition, forbidden-presence]
37
- - id: idempotency
38
- name: "Idempotency / retry"
39
- applies_hint: "money or write operations"
40
- emits: [delta]
41
- - id: i18n
42
- name: "i18n / l10n"
43
- applies_hint: "AC renders user text or formats numbers/dates/currency"
44
- emits: [presence, absolute]
45
- - id: a11y
46
- name: "a11y"
47
- applies_hint: "any rendered surface"
48
- emits: [presence, absolute]
49
- - id: responsiveness
50
- name: "Responsiveness / layout"
51
- applies_hint: "rendered surface"
52
- emits: [presence, forbidden-presence]
53
- - id: empty_state
54
- name: "Empty / null / zero state"
55
- applies_hint: "list / search / collection AC"
56
- emits: [presence]
57
- - id: overflow_underflow
58
- name: "Overflow / underflow"
59
- applies_hint: "numeric or quantity AC (R9: explicit underflow/overflow)"
60
- emits: [forbidden-presence]
61
- - id: persistence
62
- name: "Persistence / refresh"
63
- applies_hint: "AC asserts durable state"
64
- emits: [absolute]
65
- - id: temporal
66
- name: "Time / timezone / expiry"
67
- applies_hint: "AC involves dates, TTLs, schedules"
68
- emits: [state-transition, forbidden-presence]
69
- - id: currency
70
- name: "Currency / rounding"
71
- applies_hint: "money AC"
72
- emits: [absolute]
73
- - id: pagination
74
- name: "Pagination / sort / filter"
75
- applies_hint: "list / search AC"
76
- emits: [absolute, presence]
77
- - id: file_media
78
- name: "File / media"
79
- applies_hint: "upload surface"
80
- emits: [forbidden-presence]
81
- - id: notification
82
- name: "Notification / async-effect"
83
- applies_hint: "AC produces an out-of-band effect (email/SMS/push)"
84
- emits: [presence, delta]
85
- `;var Ye={"web-form":`
86
- id: web-form
87
- name: "Web form"
88
- version: 1
89
- applies_when: >
90
- The AC concerns a data-entry form: input fields, required fields, submit,
91
- validation messages.
92
- candidate_checks:
93
- - id: field-validation
94
- family: negative
95
- measurable_example: "Enter 'abc' in a numeric quantity field \u2192 inline error 'must be a number', value not accepted"
96
- emits: forbidden-presence
97
- - id: required-fields
98
- family: negative
99
- measurable_example: "Submit with a required field empty \u2192 submit blocked, field flagged"
100
- emits: forbidden-presence
101
- - id: formats
102
- family: negative
103
- measurable_example: "Email without @ rejected; valid accepted"
104
- emits: forbidden-presence
105
- - id: empty-state
106
- family: empty_state
107
- measurable_example: "First load: no stale values, placeholders shown"
108
- emits: presence
109
- - id: error-messages
110
- family: negative
111
- measurable_example: "Each error is specific and tied to its field"
112
- emits: presence
113
- - id: a11y
114
- family: a11y
115
- measurable_example: "Every input has a programmatic label; keyboard-only submit works"
116
- emits: presence
117
- - id: responsiveness
118
- family: responsiveness
119
- measurable_example: "No field overlap at 1280/768/375 px"
120
- emits: forbidden-presence
121
- `,"rest-graphql-api":`
122
- id: rest-graphql-api
123
- name: "REST / GraphQL API"
124
- version: 1
125
- applies_when: >
126
- The surface is an HTTP/GraphQL endpoint.
127
- candidate_checks:
128
- - id: response-shape
129
- family: api_contract
130
- measurable_example: "Body validates against the declared schema"
131
- emits: absolute
132
- - id: status-codes
133
- family: api_contract
134
- measurable_example: "GET 200, POST 201, missing 404, bad 400, unauth 401"
135
- emits: absolute
136
- - id: verbs
137
- family: idempotency
138
- measurable_example: "PUT is idempotent, POST is not"
139
- emits: delta
140
- - id: bad-payloads
141
- family: negative
142
- measurable_example: "Malformed JSON \u2192 400, never 500"
143
- emits: absolute
144
- - id: idempotency
145
- family: idempotency
146
- measurable_example: "Same POST with idempotency-key twice \u2192 one effect"
147
- emits: delta
148
- - id: pagination
149
- family: pagination
150
- measurable_example: "Page beyond last \u2192 empty list, not error; cursor stable"
151
- emits: absolute
152
- - id: versioning
153
- family: api_contract
154
- measurable_example: "v1 contract unchanged after v2 ships"
155
- emits: absolute
156
- - id: rate-limits
157
- family: api_contract
158
- measurable_example: "Over the limit \u2192 429 with retry-after"
159
- emits: absolute
160
- `,"mobile-native":`
161
- id: mobile-native
162
- name: "Mobile native"
163
- version: 1
164
- applies_when: >
165
- iOS/Android native surface.
166
- candidate_checks:
167
- - id: interruptions
168
- family: state_flow
169
- measurable_example: "Incoming call mid-flow \u2192 state preserved on return"
170
- emits: state-transition
171
- - id: network-transitions
172
- family: state_flow
173
- measurable_example: "wifi\u2192cellular\u21924G drop: no data loss, graceful retry"
174
- emits: state-transition
175
- - id: permissions
176
- family: negative
177
- measurable_example: "Deny camera \u2192 feature degrades, no crash"
178
- emits: forbidden-presence
179
- - id: orientation
180
- family: persistence
181
- measurable_example: "Rotate mid-form \u2192 input preserved"
182
- emits: absolute
183
- - id: deep-links
184
- family: state_flow
185
- measurable_example: "Cold-start deep link lands on the right screen with auth"
186
- emits: state-transition
187
- - id: state-persistence
188
- family: persistence
189
- measurable_example: "Kill + relaunch \u2192 resume where left off"
190
- emits: absolute
191
- - id: localization
192
- family: i18n
193
- measurable_example: "Device locale switch reformats and re-translates"
194
- emits: presence
195
- `,"stateful-flow":`
196
- id: stateful-flow
197
- name: "Stateful flow"
198
- version: 1
199
- applies_when: >
200
- Multi-step wizard / checkout / onboarding.
201
- candidate_checks:
202
- - id: valid-transitions
203
- family: state_flow
204
- measurable_example: "Each step advances only when its precondition is met"
205
- emits: state-transition
206
- - id: invalid-transitions
207
- family: state_flow
208
- measurable_example: "Can't jump to step 3 with step 2 incomplete"
209
- emits: forbidden-presence
210
- - id: back-and-abandon
211
- family: state_flow
212
- measurable_example: "Back from step 3, then abandon \u2192 no partial commit"
213
- emits: forbidden-presence
214
- - id: refresh-persistence
215
- family: persistence
216
- measurable_example: "Reload at step 2 \u2192 still at step 2 with data"
217
- emits: absolute
218
- - id: resume
219
- family: persistence
220
- measurable_example: "Return later \u2192 resume the saved flow"
221
- emits: absolute
222
- - id: double-submission
223
- family: idempotency
224
- measurable_example: "Double-click submit \u2192 exactly one submission"
225
- emits: delta
226
- `,"data-crud":`
227
- id: data-crud
228
- name: "Data CRUD"
229
- version: 1
230
- applies_when: >
231
- A persisted record.
232
- candidate_checks:
233
- - id: crud-round-trip
234
- family: crud
235
- measurable_example: "Create \u2192 read shows it \u2192 update \u2192 read shows the change \u2192 delete \u2192 read 404"
236
- emits: state-transition
237
- - id: retry-safety
238
- family: idempotency
239
- measurable_example: "Retried create with same key \u2192 one row"
240
- emits: delta
241
- - id: concurrency-lost-update
242
- family: concurrency
243
- measurable_example: "Two writers, last must not silently clobber \u2192 conflict surfaced"
244
- emits: forbidden-presence
245
- - id: delete-cascade
246
- family: crud
247
- measurable_example: "Delete parent \u2192 children handled per rule"
248
- emits: state-transition
249
- - id: referential-consistency
250
- family: crud
251
- measurable_example: "Can't create a child for a missing parent"
252
- emits: forbidden-presence
253
- `,"auth-gated":`
254
- id: auth-gated
255
- name: "Auth gated"
256
- version: 1
257
- applies_when: >
258
- Behind login/role.
259
- candidate_checks:
260
- - id: login-gate
261
- family: auth
262
- measurable_example: "Anonymous \u2192 redirected to login, not the resource"
263
- emits: forbidden-presence
264
- - id: role-permission-matrix
265
- family: auth
266
- measurable_example: "For each role \xD7 action: allowed/denied as specified"
267
- emits: absolute
268
- - id: cross-user-record
269
- family: auth
270
- measurable_example: "User A cannot read/edit user B's record by id"
271
- emits: forbidden-presence
272
- - id: token-session-expiry
273
- family: auth
274
- measurable_example: "Expired token \u2192 401/redirect, no stale access"
275
- emits: forbidden-presence
276
- - id: privilege-escalation
277
- family: auth
278
- measurable_example: "Non-admin cannot reach an admin action by direct URL/API"
279
- emits: forbidden-presence
280
- `,"search-list":`
281
- id: search-list
282
- name: "Search / list"
283
- version: 1
284
- applies_when: >
285
- Search results / list views.
286
- candidate_checks:
287
- - id: pagination
288
- family: pagination
289
- measurable_example: "First/last/empty page correct; total accurate"
290
- emits: absolute
291
- - id: sorting
292
- family: pagination
293
- measurable_example: "Sort asc/desc actually orders; ties stable"
294
- emits: absolute
295
- - id: filtering
296
- family: pagination
297
- measurable_example: "Each filter narrows correctly; combined filters AND"
298
- emits: absolute
299
- - id: empty-state
300
- family: empty_state
301
- measurable_example: "No results \u2192 friendly empty state, not blank/error"
302
- emits: presence
303
- - id: invalid-input
304
- family: negative
305
- measurable_example: "Garbage query \u2192 no crash, sane result"
306
- emits: forbidden-presence
307
- - id: length-limits
308
- family: bva
309
- measurable_example: "Max-length query handled"
310
- emits: absolute
311
- - id: locale
312
- family: i18n
313
- measurable_example: "Locale-correct collation/casing"
314
- emits: presence
315
- `};var Je=`
316
- version: 1
317
- principles:
318
- - "Each step is one complete OBJECTIVE the browser agent achieves autonomously \u2014 state the goal and the path, never low-level actions (the agent emits its own actions)."
319
- - "One objective (or tightly-related items of one goal) per step; unrelated goals split."
320
- - "Verbose path: name site, page, section, panel, control, state \u2014 'On the search results page for Noida, in the filter panel's Budget section, set min to 50L and max to 1Cr'."
321
- - "Self-contained: concrete values inline; never 'as defined in the scenario' \u2014 the agent cannot see the graph."
322
- - "Browser-only: the agent authors/runs BROWSER tests. Direct API calls and the page's own network traffic ARE in scope; native-app-only behavior, out-of-band email/SMS, backend state with no browser surface are NOT."
323
- verification:
324
- - "Phrase checks against the analyzer that observes them:"
325
- - "Visual \u2014 visible text, labels, counts, prices ('verify the price is 29.99', 'the Sold out label is shown')."
326
- - "Textual/DOM \u2014 element states/attributes ('the Add button is disabled', 'the placeholder of the search box is \u2026')."
327
- - "URL \u2014 'URL contains /checkout', 'redirected to /login'. Title \u2014 'page title contains \u2026'."
328
- - "DevTools/Network \u2014 'no API calls returned 5xx', 'the POST /api/login returned 200' (covers direct API calls too)."
329
- - "DevTools/Console \u2014 'no console errors'. Performance \u2014 'LCP under 2500ms'. Cookies/localStorage \u2014 'a cookie named session_id exists'."
330
- - "Assertions: 'Assert/Verify/Confirm \u2026'. Extractions: 'Store \u2026 as name' \u2014 vague verbs (read/tell/report) do NOT persist values."
331
- - "Baselines/deltas are EXTRACTIONS: 'store the result count as baseline_count' BEFORE the action; compare after. Never an abstract 'capture the state'."
332
- variables:
333
- - "Credentials and environment values are {{name}} variables; concrete domain values from the source stay literal."
334
- - "A value no evidence supplies (start URL, test account, seed data) is ASKED for \u2014 actual value or a variable name \u2014 never invented."
335
- pitfalls:
336
- - "A test without a starting URL cannot run \u2014 the first step names it."
337
- - "'Test the checkout flow' has no end state \u2014 state what done looks like."
338
- - "Do not cram many unrelated operations into one step; do not reference data outside the step."
339
- `;var gt=["presence","forbidden-presence","count","delta","state-transition","absolute","bound","propagation","latency","graded"];function et(t,e){for(let n of t)if(!gt.includes(n))throw new Error(`${e}: emits '${n}' is not an oracle kind`)}function Xe(t,e){let n=se(t);if(!n||!Array.isArray(n.techniques))throw new Error(`${e}: expected { techniques: [...] }`);for(let s of n.techniques){if(!s.id||!s.name||!s.applies_hint||!Array.isArray(s.emits))throw new Error(`${e}: technique '${s?.id??"?"}' missing id/name/applies_hint/emits`);et(s.emits,`${e}: technique '${s.id}'`)}return n.techniques}function Ze(t,e){let n=se(t);if(!n||!n.id||!n.name||!n.applies_when||!Array.isArray(n.candidate_checks))throw new Error(`${e}: profile missing id/name/applies_when/candidate_checks`);for(let s of n.candidate_checks){if(!s.id||!s.family||!s.measurable_example||!s.emits)throw new Error(`${e}: candidate_check '${s?.id??"?"}' missing id/family/measurable_example/emits`);et([s.emits],`${e}: check '${s.id}'`)}return n}function tt(t){let e=new Map(Xe(Qe,"packaged techniques").map(s=>[s.id,s])),n=Z(t,"design","techniques.yaml");if(ue(n))for(let s of Xe(ge(n,"utf8"),n))e.set(s.id,s);return[...e.values()]}function st(t){let e=new Map(Object.entries(Ye).map(([s,g])=>[s,Ze(g,`packaged profile '${s}'`)])),n=Z(t,"design","profiles");if(ue(n))for(let s of ut(n).filter(g=>g.endsWith(".yaml")||g.endsWith(".yml")).sort()){let g=Ze(ge(Z(n,s),"utf8"),Z(n,s));e.set(g.id,g)}return[...e.values()]}function it(t){let e=Z(t,"design","runner-grammar.yaml");return ue(e)?ge(e,"utf8"):Je}function ee(t,e){return!t.superseded.has(e)}function pe(t,e,n){return{cid:e,logical_id:t.nameOf.get(e)??null,content:n}}async function nt(t,e,n,s,g){let r=await Ne(t,"search_similar",{text:e,label:n,k:s},g);return r.ok&&Array.isArray(r.result)?r.result:[]}async function rt(t,e,n={}){let s=F(t),g=s.resolve(e);if(!g)throw new Error(`assembleDesignContext: unknown use-case '${e}' (run designGate first)`);let r=g.tip,D=s.getNode(r);if(!D||D.label!==V.USECASE)throw new Error(`assembleDesignContext: '${e}' is not a use-case (run designGate first)`);let G=s.derivesInto(r).map(u=>({source_id:u.props.source_id??null,anchor:u.props.anchor??null})),x=[],E=new Set;for(let{cid:u,content:k}of s.byLabel(V.SCENARIO))ee(s,u)&&s.edgesFrom(u).some(y=>y.type===J.BELONGS_TO&&y.dst===r)&&(x.push(pe(s,u,k)),E.add(u));let S=[];for(let{cid:u,content:k}of s.byLabel(V.AC)){if(!ee(s,u))continue;let y=s.edgesFrom(u).find(T=>T.type===J.SCOPED_TO);!y||y.dst!==r&&!E.has(y.dst)||S.push({...pe(s,u,k),scoped_to:y.dst})}let v=Array.isArray(D.content.criteria)?D.content.criteria:[],f=[D.content.title,D.content.description,...v].filter(Boolean).join(`
340
- `),L=(await nt(s,f,V.SCENARIO,10,n.embedSearch)).filter(u=>!E.has(u.cid)),B=[],$=new Set,p=[],h=[r],w=new Set([r]);for(;h.length>0;){let u=h.shift();for(let k of s.edgesFrom(u)){if(k.type!==J.DEPENDS_ON||s.nodeLabel.get(k.dst)!==V.USECASE)continue;let y=s.tipOf(k.dst);w.has(y)||(w.add(y),p.push(y),h.push(y))}}for(let u of p){let k=`depends_on ${s.nameOf.get(u)??u.slice(0,19)}`;for(let{cid:y}of s.byLabel(V.SCENARIO))if(ee(s,y)&&s.edgesFrom(y).some(T=>T.type===J.BELONGS_TO&&T.dst===u))for(let T of s.edgesInto(y)){if(T.type!==J.AUTOMATES||!ee(s,T.src)||$.has(T.src))continue;$.add(T.src);let Q=String(s.getNode(T.src)?.content.title??"");B.push({cid:T.src,logical_id:s.nameOf.get(T.src)??null,title:Q,via:k})}}for(let u of await nt(s,f,V.TEST,5,n.embedSearch)){let{cid:k,title:y}=u;$.has(k)||($.add(k),B.push({cid:k,logical_id:s.nameOf.get(k)??null,title:y??"",via:"similar"}))}let P=s.byLabel(V.STYLENOTE).filter(u=>ee(s,u.cid)).sort((u,k)=>u.cid<k.cid?-1:1).slice(0,5).map(u=>`${String(u.content.statement)} [${String(u.content.learned_from_kind)}]`);return{usecase:pe(s,r,D.content),cites:G,committed_acs:S,existing:{scenarios:x,reuse_candidates:L},import_candidates:B,style_notes:P,techniques:tt(t),profiles:st(t),runner_grammar:it(t),budget:{...n.max!=null?{max_pairs:n.max}:{},...n.strength!=null?{strength_override:n.strength}:{}},design_of:(()=>{let u=He(s,r);return u?{engine:u.engine,seq:u.seq}:null})()}}function at(t){let e=n=>{if(Array.isArray(n))return n.map(e);if(n!==null&&typeof n=="object"){let s={};for(let g of Object.keys(n).sort())s[g]=e(n[g]);return s}return n};return JSON.stringify(e(t),null,1)}import{basename as ft,dirname as ht,resolve as _t}from"path";var pt=ne,yt=new Set(["narrative","acs","scenarios","tests","exercises","gaps","scoped_to_repoints","judgements","phase"]);function bt(t){let e=/strength=(\d+)\s*(?:—|-)?\s*(.*)/.exec(t??"");return e?{strength:Number(e[1]),reason:e[2]||t||""}:{strength:2,reason:t??""}}function vt(t,e,n=new Set,s=0){return pt(e,re(t),n,s)}function wt(t,e,n,s){let g=e.scenarios?.find(v=>v.temp_ref===n.automates)??(()=>{let v=t.resolve(n.automates),f=v?t.getNode(v.tip)?.content:void 0;return f?{title:String(f.title??""),intent:String(f.intent??""),technique_notes:String(f.technique_notes??"")}:{}})(),r=[...(e.acs??[]).map(v=>({ref:v.temp_ref,text:v.text})),...n.verifies.filter(v=>!(e.acs??[]).some(f=>f.temp_ref===v)).map(v=>{let f=t.resolve(v);return{ref:v,text:f?String(t.getNode(f.tip)?.content.text??""):""}})],{test_md:D,objectives_yaml:G}=be({title:n.title,steps:n.steps,check:n.check,check_prose:n.check_prose,reuses:n.reuses},{title:g.title,intent:g.intent},r),x=ie(vt(t,D)),E=n.check,S={technique:g.technique_notes??"",profile_family:e.judgements?.find(v=>v.kind==="profile_family"&&(v.target===n.temp_ref||v.target===n.automates))?.rationale??"unspecified",anchor:E.verified_against,expected_how:e.judgements?.find(v=>v.kind==="expected_how"&&v.target===E.verified_against)?.rationale??`expected_mode: ${E.expected_mode??"inferred"}`,combinatorial:bt(g.technique_notes),surface_state:"absent",deferred_bindings:E.expected_mode==="runtime-derived"?1:0};return s.push({definitionId:x,rationale:S,anchorRef:E.verified_against,tempRef:n.temp_ref}),{temp_ref:n.temp_ref,title:n.title,automates:n.automates,verifies:n.verifies,check:n.check,definitionId:x,test_md_blob:D,objectives_blob:G,...n.reuses?.length?{reuses:n.reuses}:{},...n.surface_required!==void 0?{surface_required:n.surface_required}:{}}}function ot(t){let e=0,n=t.forceScope??null;return{terminalEventType:"design",async onProposalEvent(s){let g=a=>t.steer?(t.steer(`[auto-repair] ${a} \u2014 please re-finalize with this fixed.`),{proposal:null,error:null}):{proposal:null,error:a};if(s==null||typeof s!="object")return g("finalize_design payload is not an object");let r=s,D=Object.keys(r).filter(a=>!yt.has(a));if(D.length>0)return g(`finalize_design carries ungated/unknown section(s): ${D.join(", ")} \u2014 mintable here: acs, scenarios, tests (+gaps)`);let G=new Map;for(let a of r.tests??[]){let m=G.get(a.automates);if(m)return g(`strict 1:1 violated in-payload: ${m} and ${a.temp_ref} both automate ${a.automates}`);G.set(a.automates,a.temp_ref)}let x=F(t.contextDir);t.force&&!t.resuming&&e===0&&n===null&&(n=Ue(x,t.ucRef));let E=x.resolve(t.ucRef),S=E?String(x.getNode(E.tip)?.content.risk??"med"):"med",v=[],f=new Set([t.ucRef,E?.cid,E?.tip].filter(Boolean)),L=a=>{if(f.has(a))return!0;let m=x.resolve(a);return m!=null&&(f.has(m.cid)||f.has(m.tip))},B;try{B={...r.acs?.length?{acs:r.acs.map(a=>({temp_ref:a.temp_ref,text:a.text,kind:a.kind,risk:a.risk??S,...a.expected_answer?{expected_answer:a.expected_answer}:{},...a.scoped_to&&!L(a.scoped_to)?{scope:{type:"scenario",ref:a.scoped_to}}:{}}))}:{},...r.scenarios?.length?{scenarios:r.scenarios}:{},...r.tests?.length?{tests:r.tests.map(a=>wt(x,r,a,v))}:{},...r.exercises?.length?{exercises:r.exercises}:{},...r.gaps?.length?{gaps:r.gaps}:{},...r.scoped_to_repoints?.length?{scoped_to_repoints:r.scoped_to_repoints}:{},...r.judgements?.length?{judgements:r.judgements}:{}}}catch(a){return g(a instanceof Error?a.message:String(a))}let $=r.phase??(r.tests?.length?"tests":r.scenarios?.length?"scenarios":r.acs?.length?"acs":"design"),p=(a,m={})=>({contextDir:t.contextDir,graph:a,ucRef:t.ucRef,sections:B,by:t.by,phase:$,...m,...t.templateVersion?{templateVersion:t.templateVersion()}:{},...t.engine?{engine:t.engine}:{},...n?.length?{forceScope:n}:{},...t.because?{reason:t.because}:{},finalizeTestBody:(()=>{let A=new Map((B.tests??[]).map(I=>[I.temp_ref,I])),C=new Map,Y=(I,O,H)=>{let N=A.get(I);if(!N?.test_md_blob)return null;let z=C.get(I);if(z!==void 0)return z;if(H.has(I))return N.test_md_blob;H.add(I);let U=new Map;for(let W of N.reuses??[]){Y(W,O,H);let b=O(W);b!==null&&b!==W&&U.set(W,b)}let q=N.verifies.map(O).filter(W=>W!==null),K=_e(ye(N.test_md_blob,U),q);return C.set(I,K),K};return(I,O)=>{if(!I.test_md_blob)return null;let H=Y(I.temp_ref,O,new Set)??I.test_md_blob;if(H===I.test_md_blob)return null;let N=z=>{for(let U of A.keys())if(O(U)===z){let q=Y(U,O,new Set);if(q!==null)return{body:q,cycleKey:`batch:${z}`,next:N}}return re(x)(z)};return{test_md_blob:H,definitionId:ie(ne(H,N))}}})()}),h;if(t.protocol){let a=t.generationTicket,m=await Te(t.protocol,{verb:"design",ucTargets:[{ref:t.ucRef}],newBuCandidates:[],sourcePins:[],readBasis:x.latestHash,...a?{generationTicket:a}:{}},A=>{let C=me(p(A.graph,{eventIds:A.eventIds("design",1),sid:A.sid,...a&&!t.generationStamped?{generationTicket:a}:{}}));return C.errors!==null?{errors:C.errors}:{result:C,record:C.record}});m.ok&&"result"in m?(h=m.result,a&&!t.generationStamped&&(t.generationStamped=!0,t.generationTicket={...a,expected_prev_gen:a.next_gen})):m.ok?h={record:null,errors:null,minted:{},logicalIds:{},superseded:[],warnings:["commit already applied (recommit)"],finalizedTests:{}}:h={record:null,errors:m.kind==="validation"?m.errors:m.kind==="contended"?[{code:m.err.code,detail:`${t.ucRef} is held by ${m.err.holder?.owner_sid??"another session"}${m.err.holder?.alive?" (live)":" (stale)"} \u2014 try another use-case or wait for it to free`}]:m.kind==="drifted"?m.asks.map(C=>({code:"DRIFTED",detail:C.detail})):[{code:"UNSETTLED",detail:`concurrent activity kept moving the store (${m.attempts} attempts) \u2014 retry when the store is quieter`}],minted:{},logicalIds:{},superseded:[],warnings:[],finalizedTests:{}}}else h=me(p(x));if(h.errors)return g("design commit failed: "+h.errors.map(a=>`${a.code}: ${a.detail}`).join("; "));let w=h.warnings.filter(a=>a.includes("\u2014 committed anyway; approve"));for(let a of h.warnings)(!w.includes(a)||w.length===1)&&t.note(`warning: ${a}`);w.length>1&&t.note(`warning: ${w.length} 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`);let P=(a,m)=>a?`${a} ${m}${a>1?"s":""}`:null,u=[P(r.acs?.length,"AC"),P(r.scenarios?.length,"scenario"),P(r.tests?.length,"test"),P(r.gaps?.length,"gap")].filter(Boolean);t.aliases?.(Object.entries(h.minted).map(([a,m])=>({ref:a,cid:m,...h.logicalIds[a]?{id:h.logicalIds[a]}:{}})));{let a=`saved ${u.join(" \xB7 ")||"judgements/wiring"} as drafts`;(t.commitLine??t.note)(a)}let k=F(t.contextDir);t.onCommitted?.(k);for(let a of v){let m=h.logicalIds[a.anchorRef]??h.minted[a.anchorRef];Ve(t.contextDir,h.finalizedTests[a.tempRef]??a.definitionId,{...a.rationale,anchor:m??a.rationale.anchor})}try{let a=Object.values(h.minted).filter(m=>k.getNode(m)?.label==="test");if(a.length>0){let m=ht(_t(t.contextDir)),A=We({graph:k,cids:a,cwd:m});A.wrote.length>0&&t.note(`\u2692 wrote ${A.wrote.map(C=>ft(C.path)).join(" \xB7 ")}`);for(let C of A.refused)t.note(`warning: could not create the test file for ${C.id} \u2014 ${C.reason}`)}}catch(a){t.note(`warning: the design was saved, but its test file could not be created (${a instanceof Error?a.message:String(a)})`)}t.event?.({type:"commit",acs:r.acs?.length??0,scenarios:r.scenarios?.length??0,tests:r.tests?.length??0,gaps:r.gaps?.length??0,warnings:h.warnings.length,minted:Object.entries(h.minted).map(([a,m])=>({temp_ref:a,cid:m,...h.logicalIds[a]?{logical_id:h.logicalIds[a]}:{}}))}),e+=1,n!==null&&(n=h.forceScopeRemaining??n,t.onForceScope?.(n));let y=Oe({verb:"design",commitN:e,ucRef:t.ucRef,phase:$,committed:Object.entries(h.minted).map(([a,m])=>({temp_ref:a,cid:m,...h.logicalIds[a]?{logical_id:h.logicalIds[a]}:{}})),warnings:h.warnings},k),T=y.event.parity?.missing??[],Q=!!r.tests?.length&&T.length===0;return{proposal:h,error:null,receipt:y,...Q?{sessionComplete:Q}:{}}}}}function ct(t,e){return{type:"run_config",version:1,session_id:e.session_id,mode:e.mode,source:{source_id:`design:${t.usecase.logical_id??e.ucCid.slice(0,19)}`,source_cid:e.ucCid,kind:"design_context",numbered_text:at({...t,session_mode:e.mode})},existing_use_cases:[],read_basis:e.readBasis,max_free_text_rounds:2,graph_reads:!0,verb:"design",chat:!0,design_budget:t.budget,topology:e.topology}}function Dt(t,e){return{terminalEventType:"design",async onProposalEvent(n){let s=n??{},g=["acs","scenarios","tests","gaps"].map(r=>s[r]?.length?`${s[r].length} ${r}`:null).filter(Boolean).join(" \xB7 ");return t(`plan: finalize_design \u2014 ${g||"wiring/judgements only"} (nothing committed)`),t(JSON.stringify(s,null,2)),e?.({type:"plan",payload:s}),{proposal:s,error:null}}}}async function Ds(t,e){let n=F(e.contextDir),s=null,g=null,r=t.useCase;if(t.resume){try{{let d=await Fe(e.contextDir,t.resume,n,{deps:{onWarn:_=>e.out(`note: ${_}`)}});g=d,s=d.handle,d.drift.length>0&&(e.out(`note: sources changed since the pause: ${d.drift.map(_=>_.subject).join(", ")} \u2014 the design continues against the current versions`),e.emit?.({type:"stale_basis",sources:d.drift.map(_=>_.subject)}))}}catch(d){if(d instanceof Se||d instanceof de)return e.out(`error: ${d.message}`),e.emit?.({type:"error",message:`error: ${d.message}`}),d instanceof de||d.code==="SESSION_MISSING"||d.code==="SESSION_EXPIRED"?2:1;throw d}let i=s.state,c=qe(i.verb,"design",t.resume);if(c)return e.out(c.message),e.emit?.({type:"error",message:c.message,code:c.code}),s.release(),2;if(r&&i.use_case&&r!==i.use_case){let d=`session ${t.resume} was designing ${i.use_case}; --use-case ${r} RETARGETS it`;if(!(t.confirmRetarget?await t.confirmRetarget(`${d} \u2014 continue with the new target?`):!1))return e.out(`error: ${d} \u2014 resume without --use-case to continue ${i.use_case}, or start a fresh session on ${r}`),e.emit?.({type:"error",code:"RETARGET_MISMATCH",message:d}),s.release(),2}if(r=r??i.use_case,i.uc_tip&&r){let d=n.resolve(r)?.tip;if(d&&d!==i.uc_tip){let _=`the use-case changed since the pause (${i.uc_tip.slice(0,19)}\u2026 \u2192 ${d.slice(0,19)}\u2026)`;if(!(t.confirmRetarget?await t.confirmRetarget(`${_} \u2014 re-ground and continue against the new version?`):!1))return e.out(`error: ${_} \u2014 resume interactively to re-ground, or abandon this session`),e.emit?.({type:"error",code:"UC_TIP_MOVED",message:_}),s.release(),2;e.emit?.({type:"stale_basis",usecase:r})}}let l=Ke(n,i.target_pins);if(l.length>0){let d=`items this session pinned have changed since it paused: ${l.map(R=>`${R.ref}${R.now===null?" (now gone)":""}`).join(", ")}`;if(!(t.confirmRetarget?await t.confirmRetarget(`${d} \u2014 re-ground and continue?`):!1))return e.out(`error: ${d} \u2014 resume interactively to re-ground, or abandon`),e.emit?.({type:"error",code:"TARGET_PIN_MOVED",message:d}),s.release(),2;s.save({target_pins:(i.target_pins??[]).map(R=>({ref:R.ref,cid:n.resolve(R.ref)?.tip??R.cid}))})}let o=[...new Set([...s.state.held_receipts??[],...g?.view.kane?.held_receipts??[]])];if(o.length>0)if(e.chat?.holdReceipt)for(let d of o)e.chat.holdReceipt(d);else e={...e,initialMessage:[o.join(`
341
-
342
- `),e.initialMessage].filter(Boolean).join(`
343
-
344
- `)};if(!r)return e.out(`error: session ${t.resume} predates use-case persistence \u2014 re-supply --use-case <ref>`),e.emit?.({type:"error",message:`error: session ${t.resume} predates use-case persistence \u2014 re-supply --use-case <ref>`}),s.release(),2}let D=t.resume?void 0:t.phase,G=!1;if(D!==void 0){let{checkPhaseEntry:i,phaseEntryCmd:c,phaseLadderFor:l}=await import("./phase-seed-52LRE3LH.js");G=l(e.contextDir,n,r).length>0;let o=i(e.contextDir,n,r,D);if(!o.ok&&o.code==="UNKNOWN_PHASE")return e.out(`error: ${o.message}`),e.emit?.({type:"error",code:"UNKNOWN_PHASE",message:o.message}),s?.release(),2;if(!o.ok&&o.code==="PHASE_ORDER"){let d=t.askPhaseEntry?await t.askPhaseEntry({message:o.message,earliest:o.earliest}):"cancel";if(d==="earliest")e.out(`starting at ${o.earliest} instead (${o.missing.join(", ")} not committed yet)`),D=o.earliest;else if(d==="proceed")e.out(`note: entering at ${D} with ${o.missing.join(", ")} uncommitted \u2014 proceeding on your say-so`),e.emit?.({type:"phase_entry_override",phase:D,missing:o.missing});else{let _=(t.mode??"interactive")==="agent",R=c(r,o.earliest,_);return e.out(`error: ${o.message}`),e.emit?.({type:"error",code:"PHASE_ORDER",message:o.message,next:[{cmd:R,why:`${o.earliest} is the earliest uncommitted phase for ${r}`,title:`Start at ${o.earliest}`}]}),s?.release(),2}}}let x=!!(t.force||s?.state.force),E=!!(t.resume&&s),S=ze(n,r,x||E||G);if(!S.ok){let i=(t.mode??"interactive")==="interactive";if(S.wall&&i&&t.askDesignEntry){let{captureForceScope:c}=await import("./design-committer-BQUWD6AC.js"),l=c(n,r).length,o=await t.askDesignEntry({wall:S.wall.kind,message:S.message,display:S.wall.display,impactPairs:l});if(o.pick==="redesign"||o.pick==="proceed"){if(!o.because.trim())return e.out("a redesign needs a reason (--because) \u2014 nothing executed"),s?.release(),2;e.out(o.pick==="redesign"?`redesigning ${S.wall.display} (${l} pair(s) superseded) \u2014 because: ${o.because.trim()}`:`proceeding against the stale design (noted) \u2014 because: ${o.because.trim()}`),t={...t,force:!0,because:t.because??o.because.trim()},x=!0}else return o.pick==="view"?(e.out(`view the existing design: kane-cli context view ${S.wall.display}`),s?.release(),0):o.pick==="refresh"?(e.out(`refresh it first: kane-cli maintain evolve ${S.wall.display}`),s?.release(),0):(e.out("nothing executed \u2014 pick another use-case (bare `kane-cli design tests` lists them)"),s?.release(),0)}else{e.out(`design: ${S.message}`);let c=S.wall&&t.mode==="agent"?[{cmd:`kane-cli context view ${S.wall.display}`,why:"view the existing design",title:"View the design"},...S.wall.kind==="designed-stale"?[{cmd:`kane-cli maintain evolve ${S.wall.display}`,why:"the use-case moved since the design \u2014 evolve refreshes it",title:"Evolve the design"}]:[],{cmd:`kane-cli design tests --use-case ${S.wall.display} --force --mode agent`,why:"redesign \u2014 supersedes the live scenario+test pairs",title:"Redesign"}]:void 0;return e.emit?.({type:"gate_refused",message:S.message,...c?{next:c}:{}}),s?.release(),S.code}}if(e.preflightTurn){let i=await e.preflightTurn();if(!i.ok)return e.out(i.message??"error: turn-endpoint preflight failed"),e.emit?.({type:"error",message:i.message??"error: turn-endpoint preflight failed",code:"PREFLIGHT"}),s?.release(),2}let v={contextDir:e.contextDir,resolveAlias:i=>Ae(i,{env:process.env,auth:e.auth}),embed:(i,c)=>Ie(i,c,{env:process.env,auth:e.auth})};e.chat?.setWorking?.("assembling context\u2026");let f=await rt(e.contextDir,r,{max:t.max,strength:t.strength,embedSearch:v});if(t.priorDesign!==void 0&&(f.prior_design=t.priorDesign),t.changeDelta!==void 0&&(f.change_delta=t.changeDelta),t.because&&(f.because=t.because),D!==void 0){let{buildPhaseSeed:i}=await import("./phase-seed-52LRE3LH.js"),c=i(e.contextDir,n,r,D);f.prior_design===void 0&&c.priorDesign!==void 0&&(f.prior_design=c.priorDesign),f.entry_phase=D,c.phaseLadder.length>0&&(f.phase_ladder=c.phaseLadder)}let L=e.now?.()??new Date,B=`${L.toISOString().replace(/[-:]/g,"").slice(0,15)}-${St(2).toString("hex")}`,$=t.mode??"interactive",p=g?{...g.spawnConfig,mode:$}:ct(f,{session_id:t.resume??`design-${B}`,mode:$,ucCid:f.usecase.cid,readBasis:n.latestHash,topology:Me("design")}),h={current:null};if(p.resume&&"schema"in p.resume){let i=p.resume.binding?.template_version;typeof i=="string"&&(h.current=i)}if(t.plan?p.chat=!1:p.chat=!0,t.resume&&s){g||(p.resume={agent_state:s.state.agent_state}),e.out(`resuming design session ${t.resume}`),s.state.assumed.length>0&&e.out(`note: ${s.state.assumed.length} default(s) were assumed while you were away \u2014 kane-cli context sessions show ${t.resume} lists them`);try{let{readRecords:i}=await import("./records-5SVUXJBW.js"),c=i(e.contextDir).records.filter(l=>l.sid===t.resume).map(l=>l.design_phase).filter(l=>l!=null&&typeof l.phase=="string");if(c.length>0){let l=c.map(d=>`${d.phase}${d.completeness==="partial"?" (partial)":""}`).join(" \u2192 "),o=`[kane] durable record for this session (${t.resume}) on ${r}: design phases already COMMITTED \u2014 ${l}. Those finalizes landed; do not re-send them. Continue from the next uncommitted phase, or finish if the design is complete.`;e={...e,initialMessage:[e.initialMessage,o].filter(Boolean).join(`
345
-
346
- `)}}}catch{}t.message&&(e={...e,initialMessage:[e.initialMessage,t.message].filter(Boolean).join(`
347
-
348
- `)})}let w=e.telemetry?.enabled?e.telemetry:void 0,P=w?he(w.ids.context_instance_id??null,"design",w.ids.session_id):fe(e.contextDir,"logs",`design-${B}.log`);kt(dt(P),{recursive:!0}),e.out(`trace: ${oe(P)}`),w&&e.out(w.banner()),e.emit?.({type:"run_start",mode:$,trace:P,use_case:r});let u=(i,c,l)=>{try{xt(P,JSON.stringify({ts:new Date().toISOString(),level:i==="error"?"error":"info",run_id:w?.ids.operation_id,...w?{user_session_id:w.ids.session_id}:{},kind:i,session_id:l,data:c})+`
349
- `)}catch{}w?.wireTrace(i,c,l)},k=null,y={current:n},T={detach:null},Q=()=>{let i=T.detach;T.detach=null,i&&i()},a=(i,c)=>{let l=s;if(!l)return{};let o=i.ask,d=je({contextDir:i.contextDir,cwd:dt(i.contextDir),handle:l,note:_=>i.chat?i.chat.note(_):i.out(_),graphSlot:c,...i.now?{now:i.now}:{}});if(i.chat?.attachIngest){let _=i.chat;T.detach=_.attachIngest(async R=>{try{l.save({ingest_registry:le(l.state.ingest_registry,R,i.now?.()??new Date)});let j=await d({id:`attach-${l.state.sid}-${(l.state.ingest_registry??[]).length}`,ref:R,purpose:null});return j.ok?(_.deferBatch({source_id:j.result.source_id,cid:j.result.cid}),{ok:!0}):{ok:!1,error:j.error.message}}catch(j){return{ok:!1,error:j instanceof Error?j.message:String(j)}}})}return{ask:async _=>{let R=await o(_);if(Array.isArray(R)){let j=R.filter(M=>{if(M.free_text==null||M.free_text.trim()==="")return!1;let te=_.find(mt=>mt.id===M.id);return M.selected_index!=null&&te?.options[M.selected_index]?.input===!0}).map(M=>M.free_text.trim());if(j.length>0){let M=l.state.ingest_registry;for(let te of j)M=le(M,te,i.now?.()??new Date);l.save({ingest_registry:M})}}return R},ingest:d}};e.nested||e.chat?.attachOnCommitted?.(i=>{y.current=i});let m="";if(e.chat&&!t.plan&&!e.nested){let i=Pe({contextDir:e.contextDir,graph:F(e.contextDir),sessionStamp:p.session_id,by:e.by??{kind:"human",id:"owner"}});i.errors===null||i.errors[0]?.code==="CONV_SOURCE_EXISTS"?(m=i.sourceId,e.chat.attachConversationSource?.(m),y.current=F(e.contextDir)):e.out(`warning: notes you add in chat can't be saved to the context this session (${i.errors[0]?.detail})`)}let A=F(e.contextDir),C;if(!t.plan){let i=Ee(A,r);if(E&&i!==null&&i.live){let c=A.resolve(r);C={uc_root:Re(A,c.cid),next_gen:i.gen,expected_prev_gen:i.gen}}else{let c=Ce(A,r,{...x?{force:!0}:{},because:t.because??(x?"forced redesign (--force)":void 0)});if("error"in c)return e.out(`design: ${c.error.detail}`),e.emit?.({type:"gate_refused",message:c.error.detail,code:c.error.code}),s?.release(),2;C=c}}let Y=we(e.contextDir,p.session_id),I=null,O=()=>{try{I?.release()}catch{}};if(!t.plan)try{I=Y.acquire([ke(A,r).key],{hold:"session",verb:"design"})}catch(i){if(i instanceof ve&&i.code==="UC_HELD"){let c=i.holder,l=`design: ${r} is being designed by another session${c?.alive===!1?` \u2014 that session looks stopped; resume it with kane-cli design tests --resume ${c?.owner_sid??"<session>"}`:""} \u2014 pick another use-case (kane-cli design tests) or wait for it to finish`;return e.out(l),e.emit?.({type:"error",code:"UC_HELD",message:l}),s?.release(),2}throw i}let H={contextDir:e.contextDir,rootSid:p.session_id,locks:Y,probe:{batchSimilar:async()=>({hits:[],degraded:!1,probeBasis:null}),recheckLocal:()=>({hits:[],uncachedNewNodes:[]})}},N=!t.plan&&$!=="ci",z=()=>Object.fromEntries((n.resolve(r)?n.edgesInto(n.resolve(r).tip):[]).filter(i=>i.type==="DERIVES"&&typeof i.props.source_id=="string").map(i=>[String(i.props.source_id),n.heads.get(String(i.props.source_id))??null])),U=!1;N&&!s&&(U=!0,s=ae(e.contextDir,{sid:p.session_id,mode:"agent",created_at:L.toISOString(),expires_at:new Date(L.getTime()+1440*60*1e3).toISOString(),agent_state:{schema:2,items:[],provider_state:""},pending:{questions:[],proposals:[]},read_basis:z(),assumed:[],corpus_cursor:{remaining:[]},conv_source:m,target_pins:n.resolve(r)?[{ref:r,cid:n.resolve(r).tip}]:[],verb:"design",use_case:r,...n.resolve(r)?.tip?{uc_tip:n.resolve(r).tip}:{},...x?{force:!0}:{},...w?{user_session_id:w.ids.session_id}:{}}));let q;if(N&&s){let{resume:i,...c}=p;$e(e.contextDir,p.session_id,{schema:De,kind:"base",sid:p.session_id,verb:"design",mode:$,created_at:L.toISOString(),run_config:c,conv_source:m||s.state.conv_source||"",...r?{use_case:r}:{},...n.resolve(r)?.tip?{uc_tip:n.resolve(r).tip}:{},store_watermark:xe(e.contextDir)}),p.checkpoints=!0,t.resume&&u("resume_kind",{kind:g?g.view.pointer===null?"bare-base":g.view.pointer.at==="final"?"pause":"crash":"v1-shim"},p.session_id);let l=g?0:s.state.checkpoint?.seq??0,o=s;q=Be({contextDir:e.contextDir,handle:o,seqBase:()=>l,peekHeldReceipts:()=>e.chat?.peekHeldReceipts?.()??[],readBasis:()=>z(),corpusCursor:()=>({remaining:[]}),onSoftCap:_=>e.out(_),onStat:_=>u("ckpt_stat",_,p.session_id),...e.now?{now:e.now}:{}});let d=q;q={...d,persist:_=>{let R=_.binding?.template_version;return typeof R=="string"&&R&&(h.current=R),d.persist(_)}}}let K=()=>{if(!s)return;let i=s.state.checkpoint;if(i){let c=$!=="interactive"?` --mode ${$}`:"";e.out(`session ${s.state.sid} kept its last checkpoint (seq ${i.seq}, ${i.ts}) \u2014 resume with: kane-cli design tests --resume ${s.state.sid}${c}`),s.release()}else if(U){try{s.complete()}catch{s.release()}try{lt(fe(e.contextDir,"sessions"))}catch{}}else s.release();s=null},W=t.plan?Dt(e.out,e.emit):ot({templateVersion:()=>h.current,contextDir:e.contextDir,ucRef:r,by:{kind:"ai",id:"design-agent"},force:x,engine:"design@1",note:i=>e.chat?e.chat.note(i):e.out(i),commitLine:i=>e.chat?e.chat.ledger({kind:"commit",ok:!0,line:i}):e.out(i),steer:e.chat?i=>e.chat.submit(i):void 0,event:e.emit,resuming:E,...s?.state.force_scope?.length?{forceScope:s.state.force_scope}:{},onForceScope:i=>{k=i},...t.because?{because:t.because}:{},aliases:e.chat?i=>e.chat.registerAliases?.(i):void 0,onCommitted:i=>{y.current=i},protocol:H,...C?{generationTicket:C}:{},...E?{generationStamped:!0}:{}});e.chat||e.out(`designing: ${f.usecase.logical_id??r} (budget ${f.budget.max_pairs!=null?`${f.budget.max_pairs} pairs`:"no ceiling"}${f.budget.strength_override?`, strength ${f.budget.strength_override}`:""})`),e.chat?.setWorking?.(`designing ${f.usecase.logical_id??r}\u2026`);let b;try{b=await ce(p,{...e,graphSlot:y,...a(e,y),...q?{checkpoint:q}:{}},new Map,n,u,W)}catch(i){throw u("error",{message:i instanceof Error?i.message:String(i),stack:i instanceof Error?i.stack:void 0},p.session_id),K(),i}finally{e.chat?.setWorking?.(null),Q()}if(b.errorCode==="binding_mismatch"&&g){let i=await e.ask([{id:"binding-mismatch",text:"this session's saved conversation is no longer accepted by the service \u2014 start the conversation fresh (committed work is kept), or stop and keep the session?",risk:"high",rationale:"the service refused the saved conversation on the first turn after resume",options:[{label:"start fresh",detail:"continue with a fresh conversation \u2014 earlier answers may be re-asked"},{label:"stop",detail:"stop here; the session stays resumable"}],recommended_index:1,allow_free_text:!1}]);if((Array.isArray(i)?i.find(o=>o.id==="binding-mismatch"):void 0)?.selected_index!==0){let o=`resume abandoned: binding mismatch on session ${p.session_id} \u2014 the session is preserved`;return e.out(o),e.emit?.({type:"error",message:o,code:"BINDING_MISMATCH"}),s?.release(),2}u("binding_migrate",{sid:p.session_id},p.session_id);let l=p.resume&&"schema"in p.resume?{...p.resume,binding:{}}:void 0;try{b=await ce({...p,...l?{resume:l}:{}},{...e,graphSlot:y,...a(e,y),...q?{checkpoint:q}:{}},new Map,n,u,W)}catch(o){throw u("error",{message:o instanceof Error?o.message:String(o),stack:o instanceof Error?o.stack:void 0},p.session_id),K(),o}finally{e.chat?.setWorking?.(null),Q()}}if(b.highRisk)return e.out(`error: ${b.highRisk.length} high-risk decision${b.highRisk.length===1?"":"s"} need a human \u2014 ci mode won't guess. Re-run with --mode agent to pause for review.`),e.emit?.({type:"error",message:`error: high-risk question(s) in ci mode (fail-closed): ${b.highRisk.map(i=>i.id).join(", ")}`,code:"HIGH_RISK_CI"}),K(),O(),1;if(b.paused){let i=s;i||(i=ae(e.contextDir,{sid:p.session_id,mode:"agent",created_at:L.toISOString(),expires_at:new Date(L.getTime()+1440*60*1e3).toISOString(),agent_state:b.paused.agent_state,pending:{questions:[],proposals:[]},read_basis:Object.fromEntries((n.resolve(r)?n.edgesInto(n.resolve(r).tip):[]).filter(o=>o.type==="DERIVES"&&typeof o.props.source_id=="string").map(o=>[String(o.props.source_id),n.heads.get(String(o.props.source_id))??null])),assumed:[],corpus_cursor:{remaining:[]},conv_source:m,target_pins:n.resolve(r)?[{ref:r,cid:n.resolve(r).tip}]:[],verb:"design",use_case:r,...n.resolve(r)?.tip?{uc_tip:n.resolve(r).tip}:{},...x?{force:!0}:{},...w?{user_session_id:w.ids.session_id}:{}}));try{x&&!i.state.force&&i.save({force:!0}),w&&i.state.user_session_id!==w.ids.session_id&&i.save({user_session_id:w.ids.session_id}),m&&i.state.conv_source!==m&&i.save({conv_source:m});let o=e.chat?.drainHeldReceipts?.()??[];(o.length>0||(i.state.held_receipts?.length??0)>0)&&i.save({held_receipts:o}),k!==null&&i.save({force_scope:k}),Le(i,b.paused)}catch(o){let d=i.state.checkpoint,_=`error: couldn't persist the pause for session ${i.state.sid}`+(d?` \u2014 last durable checkpoint: seq ${d.seq} @ ${d.ts}`:" \u2014 no durable checkpoint exists")+` (${o instanceof Error?o.message:String(o)})`;return e.out(_),e.emit?.({type:"error",message:_,code:"PAUSE_PERSIST_FAILED",sid:i.state.sid}),1}u("session_paused",{sid:i.state.sid},p.session_id);let c=$!=="interactive"?` --mode ${$}`:"",l=`kane-cli design tests --resume ${i.state.sid}${c}`;return e.out(`paused \u2014 resume with: ${l}`),e.emit?.({type:"session_paused",sid:i.state.sid,mode:$,resume:l,expires_at:i.state.expires_at,pending_questions:b.paused.pending.questions}),e.chat?.ledger?.({kind:"pause",sid:i.state.sid,expires_at:i.state.expires_at,resume:l,messageForm:`${l} --message "<your words>"`}),O(),3}if(b.crashed&&s?.state.checkpoint){let i=s.state.checkpoint,c=$!=="interactive"?` --mode ${$}`:"",l=`kane-cli design tests --resume ${s.state.sid}${c}`;return u("agent_crashed_resumable",{sid:s.state.sid,seq:i.seq},p.session_id),e.out(`agent crashed \u2014 session ${s.state.sid} is resumable at checkpoint seq ${i.seq} (at most the in-flight turn lost); resume with: ${l}`),e.emit?.({type:"session_paused",sid:s.state.sid,mode:$,resume:l,expires_at:s.state.expires_at,crashed:!0}),s.release(),s=null,3}if(b.error)return e.out(`error: design agent failed: ${b.error}`),e.emit?.({type:"error",message:`error: design agent failed: ${b.error}`}),K(),O(),1;if(b.proposal==null&&$!=="interactive")return e.out(`error: the design session stopped before saving anything \u2014 nothing committed (trace: ${P})`),e.emit?.({type:"error",message:`error: the design session stopped before saving anything \u2014 nothing committed (trace: ${P})`}),K(),O(),1;let X=0;if(b.proposal==null)try{let{readRecords:i}=await import("./records-5SVUXJBW.js"),c=t.resume??p.session_id;X=i(e.contextDir).records.filter(l=>l.sid===c).reduce((l,o)=>l+o.nodes.filter(d=>d.label!=="source").length,0)}catch{}if(b.proposal==null&&e.out(X>0?`done \u2014 ${X} item(s) committed in this session (earlier legs included); nothing new since the resume`:"done \u2014 nothing designed this session (no finalize before the session ended)"),b.assumedDefaults&&e.out(`assumed: ${b.assumedDefaults} default(s) auto-taken (assumed)`),s&&e.emit?.({type:"session_complete",sid:t.resume??p.session_id}),w?.event("ASR_SESSION_COMPLETE",{}),s?.complete(),U)try{lt(fe(e.contextDir,"sessions"))}catch{}if(!e.nested){let i=e.chat?.state.ledger.filter(o=>o.kind==="answer"&&o.receipt.form==="assumed").length??0,c=(b.assumedDefaults??0)+i,l=e.chat?.state.credits?.total??b.creditsTotal;e.chat?.ledger?.({kind:"summary",lines:[`designed: ${f.usecase.logical_id??r}${b.proposal==null?X>0?` (${X} item(s) committed across this session)`:" (nothing committed this session)":""}`,...c>0?[`${c} assumed default(s)`]:[],...l!==void 0?[`credits used: ${l.toFixed(1)}`]:[],`trace: ${oe(P)}`]})}return t.plan||Ge(e.contextDir),O(),0}export{Ds as a};
@@ -1,3 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{d as N}from"./chunk-GVIPTX6T.js";import{a as L,b as M}from"./chunk-BKM2LWU2.js";import{a as b,b as O,c as k}from"./chunk-2XMJ6YAE.js";import{a as y,b as R,c as T,d as m,e as I,f as w,g as r}from"./chunk-W6VD2XFO.js";import{b as x,d as A}from"./chunk-5EOX4MEY.js";import{a as E}from"./chunk-RZ4F3BHX.js";import{a as g,j as v}from"./chunk-C4G7RVJ6.js";import{platform as X,arch as $}from"os";import D from"fs";import V from"fs";import q from"path";var Y=new Set(["org_id","user_id","plan"]);function C(t){let e={machine_id:k(),env:t};try{let n=JSON.parse(V.readFileSync(A(t),"utf8"));for(let[i,s]of Object.entries(n))Y.has(i)&&typeof s=="string"&&s.length>0&&s.length<=128&&(e[i]=s)}catch{}return e}import P from"fs";import B from"path";var F=1e3,d=0,a=class t{ids;logger;opts;ended=!1;constructor(e){this.ids=e.envelope,this.logger=e.logger,this.opts=e}get enabled(){return this.logger!==null}event(e,n={}){if(!this.logger)return;let i=m(this.ids,e,n);this.logger.log(y[e],e,e,U(i))}error(e,n={}){this.logger&&(this.logger.escalate(d),this.event("ASR_ERROR",{...n,error_code:e}))}child(e,n){return new t({...this.opts,envelope:{...this.ids,operation_id:n,parent_operation_id:this.ids.operation_id,verb:"design"}})}async lateBindContext(e){if(!(!this.logger||this.ids.context_instance_id))try{let{ensureStoreIds:n}=await import("./store-id-EOSGEKVK.js"),{ids:i,cloned:s}=n(e);this.ids.context_lineage_id=i.context_lineage_id,this.ids.context_instance_id=i.context_instance_id,s&&this.event("ASR_CONTEXT_CLONED")}catch{}}agentSession(e){this.ids.agent_session_id=e}spawnEnv(){if(!this.opts.telemetryEnabled)return{};let e={TESTMUAI_USER_SESSION_ID:this.ids.session_id,TESTMUAI_OPERATION_ID:this.ids.operation_id,TESTMUAI_CLIENT_VERSION:this.opts.clientVersion,TESTMUAI_TELEMETRY_PROXY_URL:this.opts.proxyUrl};return this.ids.context_instance_id&&(e.TESTMUAI_CONTEXT_INSTANCE_ID=this.ids.context_instance_id),e}traceTee(){return e=>{if(!this.logger)return;let n=typeof e.kind=="string"?e.kind.slice(0,64):"trace",i={...U(m(this.ids,"ASR_CMD_START",{})),trace_kind:n};typeof e.code=="string"&&(i.trace_code=e.code.slice(0,64)),delete i.event,this.logger.logStep(d,`trace_${n}`,n,i)}}wireTrace(e,n,i){if(!this.logger)return;i&&this.agentSession(i);let s=n&&typeof n=="object"?n:{};switch(e){case"spawn":this.event("ASR_AGENT_SPAWN",{tier:s.tier});break;case"session_paused":this.event("ASR_SESSION_PAUSED",s);break;case"commit":this.event("ASR_COMMIT",s);break;default:this.traceTee()({kind:e,code:typeof s.code=="string"?s.code:void 0})}}banner(){return`session: ${this.ids.session_id}`}supportFooter(){return`if this keeps failing, share this id with support: ${this.ids.session_id}`}async end(e){if(!this.ended){if(this.ended=!0,this.logger)if(e.exit_code===0?this.logger.discardSteps(d):this.logger.escalate(d),this.event("ASR_CMD_END",e),this.opts.longSession)await this.logger.shutdown();else{let n=await this.logger.flushOnce(F);(n==="failed"||n==="timeout")&&I(this.logger.drainBuffer())}this.logger&&this.writeManifestLine(e.exit_code),r(null)}}writeManifestLine(e){try{let n=x(this.ids.context_instance_id??null);P.mkdirSync(B.dirname(n),{recursive:!0});let i={ts:new Date().toISOString(),session_id:this.ids.session_id,operation_id:this.ids.operation_id,agent_session_id:this.ids.agent_session_id,verb:this.ids.verb,mode:this.ids.mode,exit_code:e};P.appendFileSync(n,JSON.stringify(i)+`
3
- `,{flag:"a",mode:384})}catch{}}};function U(t){let e={event:t.event,session_id:t.session_id,operation_id:t.operation_id,verb:t.verb,mode:t.mode,component:t.component,seq:t.seq,context_lineage_id:t.context_lineage_id,context_instance_id:t.context_instance_id};t.parent_operation_id&&(e.parent_operation_id=t.parent_operation_id),t.agent_session_id&&(e.agent_session_id=t.agent_session_id);for(let[n,i]of Object.entries(t.context))e[n]=i;return e}var u=process.env.KANE_TELEMETRY_URL||v;function ve(){return process.env.TESTMUAI_BASE_URL?"custom":process.env.TESTMUAI_ENV==="stage"?"stage":"prod"}function Ee(t){let e=process.env.KANE_TELEMETRY!=="0"&&(!process.env.VITEST||process.env.KANE_TELEMETRY==="1"),n=t.env??"prod",i=null;if(t.resumeSid&&t.contextRoot)try{let o=N(t.contextRoot,t.resumeSid);o?.user_session_id&&(i=o.user_session_id)}catch{}if(!i&&t.applyPlanPath)try{let o=JSON.parse(D.readFileSync(t.applyPlanPath,"utf8"));o.telemetry?.user_session_id&&(i=o.telemetry.user_session_id)}catch{}let s=i!==null;i||(i=R());let l=null,c=null,f=!1;if(t.contextRoot&&D.existsSync(t.contextRoot))if(t.write&&e){let o=M(t.contextRoot);l=o.ids.context_lineage_id,c=o.ids.context_instance_id,f=o.cloned}else{let o=L(t.contextRoot);l=o?.context_lineage_id??null,c=o?.context_instance_id??null}let h={session_id:i,operation_id:T(),context_lineage_id:l,context_instance_id:c,verb:t.verb,mode:t.mode,component:"kane-cli"},_=null;if(e){let o=C(n),S={org_id:o.org_id??"",user_id:o.user_id??"",machine_id:o.machine_id,email:null,email_domain:"",user_type:"unknown",env:o.env,plan:o.plan??"unknown"},j=t.mode==="interactive"||t.mode==="cli"?"cli":"agent";_=new b({proxyUrl:u,sessionId:i,identity:S,device:{cli_version:g,platform:X(),arch:$(),host_agent:O(),invocation_mode:j},getToken:async()=>null}),t.longSession&&_.start()}let p=new a({envelope:h,logger:_,longSession:!!t.longSession,proxyUrl:u,clientVersion:`kane-cli/${g}`,telemetryEnabled:e});return e&&(r(h),p.event("ASR_CMD_START",{resumed:s,applied_plan:!!t.applyPlanPath}),f&&p.event("ASR_CONTEXT_CLONED"),w(async o=>{try{return(await E(u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)})).ok}catch{return!1}}).catch(()=>{})),p}export{ve as a,Ee as b};
@@ -1,6 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as X,b as Y,c as Z,d as ee}from"./chunk-UI7KULSI.js";import{m as Q,o as C}from"./chunk-W6VD2XFO.js";import{a as be}from"./chunk-6YGTRKDT.js";import{e as xe}from"./chunk-UR6MHSHU.js";function ne(l){return{command:"start",...l}}function te(l,n,s){return{command:"run",run_id:l,kind:n,...s}}function ie(l){return{command:"cancel",...l?{run_id:l}:{}}}function re(l){return{command:"ask_user_response",answer:l}}function se(){return{command:"shutdown"}}var q=Symbol("run-queue-end"),z=class{items=[];waiting=null;ended=!1;error=null;push(n){if(this.waiting){let{resolve:s}=this.waiting;this.waiting=null,s(n)}else this.items.push(n)}end(){if(this.ended=!0,this.waiting){let{resolve:n}=this.waiting;this.waiting=null,n(q)}}fail(n){if(this.error=n,this.waiting){let{reject:s}=this.waiting;this.waiting=null,s(n)}}next(){return this.items.length>0?Promise.resolve(this.items.shift()):this.error?Promise.reject(this.error):this.ended?Promise.resolve(q):new Promise((n,s)=>{this.waiting={resolve:n,reject:s}})}},A=class{env;runner;log;sessionId;spawnFn;proc=null;activeRun=null;pendingReady=null;shuttingDown=!1;finalized=!1;exitInfo=null;exitedUnexpectedly=!1;exitResolve;exited;constructor(n){this.env=n.env,this.runner=n.runner,this.log=n.log,this.sessionId=n.sessionId,this.spawnFn=n.spawn??Y;let s;this.exited=new Promise(p=>{s=p}),this.exitResolve=s}async start(n){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((p,v)=>{this.pendingReady={resolve:p,reject:v}});this.writeCommand(ne(n)),await s}async*run(n,s,p){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 '${n}'`);if(this.activeRun)throw new Error(`PersistentRunner.run overlap: '${this.activeRun.runId}' still in flight`);let v=new z,w={runId:n,queue:v};this.activeRun=w,this.writeCommand(te(n,s,p));try{for(;;){let g=await v.next();if(g===q||(yield g,g.type==="run_end"&&(g.run_id===void 0||g.run_id===n)))break}}finally{this.activeRun===w&&(this.activeRun=null)}}sendUserResponse(n){this.writeCommand(re(n))}cancel(n){this.writeCommand(ie(n))}kill(){this.proc?.child.kill("SIGTERM")}async shutdown(){this.shuttingDown=!0,this.proc&&(this.writeCommand(se()),await this.exited)}get stderr(){return this.proc?.getStderr()??""}get diedUnexpectedly(){return this.exitedUnexpectedly}writeCommand(n){let s=JSON.stringify(n)+`
3
- `;try{this.proc?.child.stdin?.write(s)}catch{}}async consume(){if(!this.proc)return;try{for await(let p of this.proc.events){if(p.type==="ready"){this.onReady();continue}this.routeEvent(p)}}catch(p){this.log?.("error","PERSISTENT_RUNNER_STREAM_ERROR","Runner stdout stream errored",{error:p instanceof Error?p.message:String(p)})}let{code:n,signal:s}=await this.proc.exited;this.onExit(n,s)}onReady(){if(this.pendingReady){let{resolve:n}=this.pendingReady;this.pendingReady=null,n()}}routeEvent(n){let s=this.activeRun;if(!s){this.log?.("warn","PERSISTENT_RUNNER_ORPHAN_EVENT","Runner event with no active run",{event_type:n.type});return}s.queue.push(n)}onExit(n,s){if(!this.finalized){if(this.finalized=!0,this.exitInfo={code:n,signal:s},this.shuttingDown||(this.exitedUnexpectedly=!0),this.exitResolve({code:n,signal:s}),this.pendingReady){let{reject:p}=this.pendingReady;this.pendingReady=null,p(new Error(`v16-runner exited before ready (code=${n}, signal=${s??"none"})`))}if(this.activeRun){let{queue:p}=this.activeRun;if(this.activeRun=null,this.shuttingDown)p.end();else{let v=this.proc?.getStderr()?.slice(-500)??"";p.fail(new Error(`v16-runner exited unexpectedly mid-run (code=${n}, signal=${s??"none"})${v?`
4
- ${v}`:""}`))}}}}};var h=xe(be(),1);function j(l,n){let s=null,p=(v,w)=>{for(let g=0;g<v.length;g++){let x=v[g],f=[...w,g];n(x)&&(s===null||f.length>s.length)&&(s=f),x.children&&x.children.length>0&&p(x.children,f)}};return p(l,[]),s}function N(l,n,s){if(n.length===0)return[...l];let p=n[0],v=[...l],w=v[p];if(n.length===1)v[p]=s(w);else{let g=n.slice(1),x=N(w.children??[],g,s);v[p]={...w,children:x}}return v}function oe(){return{steps:[],maxOrdinal:0}}function _e(l,n){if(n.type==="run_start"&&n.environment?.resolution)return{...l,resolution:n.environment.resolution};if(n.type==="step_end"&&typeof n.ordinal=="number"&&n.id){let s={id:n.id,ordinal:n.ordinal,status:n.status,...n.kind?{kind:n.kind}:{},...typeof n.duration=="number"?{duration_ms:Math.round(n.duration*1e3)}:{},...typeof n.action_id=="string"&&n.action_id?{action_id:n.action_id}:{}};return{...l,steps:[...l.steps,s],maxOrdinal:Math.max(l.maxOrdinal,n.ordinal)}}return l}function V(l){let n=l.indexOf(": ");return n>0&&n<15?l.slice(n+2):l}function W(l){return l.map(n=>{let s=n.children?W(n.children):n.children;return n.status==="running"?{...n,status:"stopped",phase:void 0,children:s}:s!==n.children?{...n,children:s}:n})}function Ue(l,n,s,p,v){let[w,g]=(0,h.useState)(!1),[x,f]=(0,h.useState)([]),[ae,T]=(0,h.useState)(null),[ue,B]=(0,h.useState)(null),[de,I]=(0,h.useState)(null),[le,J]=(0,h.useState)(null),[ce,G]=(0,h.useState)([]),[pe,H]=(0,h.useState)(null),[he,fe]=(0,h.useState)(void 0),y=(0,h.useRef)(null),E=(0,h.useRef)(null),S=(0,h.useRef)(null),b=(0,h.useRef)(0),D=(0,h.useRef)(!1),$=(0,h.useRef)(oe()),U=(0,h.useRef)(null),me=(0,h.useCallback)(async(a,_)=>{let K=U.current;if(K)try{await K}catch{}f([]),T(null),B(null),I(null),J(null),G([]),H(null),fe(a.max_steps),g(!0),S.current=null,b.current=0,$.current=oe();let k=y.current;if(k&&E.current!==a.session_id){try{k.kill()}catch{}y.current=null,E.current=null,k=null}if(!k){let e=X();if(!e){I("v16-runner not found. Build the binary with `cd v16-runner && python build.py` or ensure Python is available."),g(!1);return}let d=Z({environment:_?.environment,mode:_?.mode,assertionMode:_?.assertionMode,finalValidation:_?.finalValidation,username:a.username,accessKey:a.access_key,sessionId:a.session_id}),u=new A({env:d,runner:e,log:_?.log,sessionId:a.session_id});y.current=u,E.current=a.session_id,k=u,Q("runner",()=>{try{u.kill()}catch{}});let i={cdp_endpoint:a.cdp_endpoint,ws_endpoint:a.ws_endpoint,width:a.width,height:a.height,headless:a.headless,model:a.model,max_steps:a.max_steps,network_ws:a.network_ws,network_sse:a.network_sse,session_id:a.session_id};a.auth&&(i.auth=a.auth),a.username&&(i.username=a.username),a.access_key&&(i.access_key=a.access_key);try{await u.start(i)}catch(o){I(o instanceof Error?o.message:String(o)),g(!1),C("runner","Runner start failed"),y.current=null,E.current=null;return}}let F={...a};delete F.run_id,ee(F,{environment:_?.environment});let ye=`run-${a.run_index}`,we=a.mode==="replay"?"replay":"author",M=k,L=(async()=>{D.current=!1;for await(let e of M.run(ye,we,F)){if(D.current)break;switch($.current=_e($.current,e),e.type){case"run_start":if(e.child_id)break;if(S.current&&!S.current.isSingleFlow){let d=b.current;b.current++,f(u=>u.map((i,o)=>o===d?{...i,status:"running"}:i.status==="running"&&!i.children?.some(t=>t.status==="running")?{...i,status:i.children?.some(t=>t.status==="failed")?"failed":"passed"}:i))}break;case"bifurcation":{let d=e.flows??[],u=e.count??d.length,i={flows:d,isSingleFlow:e.is_single_flow??u<=1};J(i),S.current=i,b.current=0,f(d.map((o,t)=>({index:t+1,objective:o??`Flow ${t+1}`,status:"pending"})));break}case"step_start":{n?.("STEP_START",`Step ${e.index} started`,{index:e.index,objective:e.objective,child_id:e.child_id});let d=e.index,u=e.objective??`Step ${d}`,i=e.child_id,o=S.current&&!S.current.isSingleFlow;if(i)f(t=>{let r=j(t,c=>c.branchChildId===i)??j(t,c=>c.status==="running");return r?N(t,r,c=>{let m=(c.children??[]).map(R=>R.status==="running"&&R.childId===i?{...R,status:"stopped",phase:void 0}:R);return m.push({index:d,objective:u,status:"running",childId:i}),{...c,children:m}}):t});else if(o){let t=Math.max(0,b.current-1);f(r=>{let c=[...r];if(t>=c.length)return r;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:d,objective:u,status:"running"}),m.children=P,m.status="running",c[t]=m,c})}else f(t=>{let r=W(t);return r.some(m=>m.index===d)?r.map(m=>m.index===d?{...m,status:"running",objective:u}:m):[...r,{index:d,objective:u,status:"running"}]});break}case"step_event":{n?.("STEP_EVENT",`Step ${e.index} ${e.event}`,{index:e.index,phase:e.event,action_type:e.action_type,detail:e.detail,child_id:e.child_id});let d=e.child_id,u=S.current&&!S.current.isSingleFlow;if(e.event==="cm_init"&&e.checkpoint_count!=null){G(i=>[...i,e.checkpoint_count]);break}if(e.event==="replay_started"){H({recordingLength:e.recording_length??0});break}if(e.event==="reasoning"&&e.detail&&e.detail!=="reasoning"&&s?.(e.detail),d){let i=t=>{if(t.index!==e.index||t.childId!==d)return t;let r={phase:e.event};return e.event==="reasoning"&&e.detail&&e.detail!=="reasoning"&&(r.objective=e.detail),e.action_type&&(r.actionType=e.action_type),{...t,...r}},o=t=>t.map(r=>{let c=i(r);return c!==r?c:r.children&&r.children.length>0?{...r,children:o(r.children)}:r});f(t=>t.map(r=>r.children?{...r,children:o(r.children)}:r))}else if(u){let i=Math.max(0,b.current-1);f(o=>{let t=[...o];if(i>=t.length)return o;let r={...t[i]},c=[...r.children??[]];if(!c.some(R=>R.index===e.index&&R.childId===void 0))c.push({index:e.index,objective:`Step ${e.index}`,status:"running",phase:e.event,actionType:e.action_type});else for(let R=0;R<c.length;R++){if(c[R].index!==e.index||c[R].childId!==void 0)continue;let P={phase:e.event};e.event==="reasoning"&&e.detail&&e.detail!=="reasoning"&&(P.objective=e.detail),e.action_type&&(P.actionType=e.action_type),c[R]={...c[R],...P}}return r.children=c,t[i]=r,t})}else f(i=>i.some(t=>t.index===e.index)?i.map(t=>{if(t.index!==e.index)return t;let r={phase:e.event};return e.event==="reasoning"&&e.detail&&e.detail!=="reasoning"&&(r.objective=e.detail),e.action_type&&(r.actionType=e.action_type),{...t,...r}}):[...W(i),{index:e.index,objective:`Step ${e.index}`,status:"running",phase:e.event,actionType:e.action_type}]);break}case"step_end":{n?.("STEP_END",`Step ${e.index} ${e.status}`,{index:e.index,status:e.status,duration:e.duration,summary:e.summary,child_id:e.child_id}),p?.();let d=e.child_id,u=S.current&&!S.current.isSingleFlow;if(d){let i=t=>t.index===e.index&&t.childId===d?{...t,status:e.status,duration:e.duration,phase:void 0,objective:t.objective.startsWith("Step ")?V(e.summary||t.objective):t.objective}:t,o=t=>t.map(r=>{let c=i(r);return c!==r?c:r.children&&r.children.length>0?{...r,children:o(r.children)}:r});f(t=>t.map(r=>r.children?{...r,children:o(r.children)}:r))}else if(u){let i=Math.max(0,b.current-1);f(o=>{let t=[...o];if(i>=t.length)return o;let r={...t[i]},c=(r.children??[]).map(m=>m.index===e.index&&m.childId===void 0?{...m,status:e.status,duration:e.duration,phase:void 0,objective:m.objective.startsWith("Step ")?V(e.summary||m.objective):m.objective}:m);return r.children=c,t[i]=r,t})}else f(i=>i.map(o=>o.index===e.index?{...o,status:e.status,duration:e.duration,phase:void 0,objective:o.objective.startsWith("Step ")?V(e.summary||o.objective):o.objective}:o));{let o=S.current&&!S.current.isSingleFlow?Math.max(0,b.current-1):0,t=typeof e.ordinal=="number"&&e.id?{ordinal:e.ordinal,id:e.id}:void 0;l?.(e.index,o,e.child_id,t)}break}case"child_agent_start":{let d=e.objective??"",u=e.child_id;f(i=>{let o=j(i,t=>t.status==="running");return o?N(i,o,t=>({...t,objective:`${d} (branch)`,phase:`child: ${d.slice(0,50)}`,branchObjective:d,branchChildId:u})):i});break}case"child_agent_end":{let d=e.child_id,u=`child ${e.success?"done":"failed"}`;f(i=>{let o=j(i,t=>t.branchChildId===d);return o?N(i,o,t=>({...t,phase:u})):i.map(t=>t.phase?.startsWith("child:")?{...t,phase:u}:t)});break}case"describe_trigger":v?.(e);break;case"ask_user":T(e.question??"");break;case"run_end":f(d=>d.map(u=>u.status==="running"?{...u,status:e.status,phase:void 0}:u)),g(!1),B(e);break;case"error":g(!1),I(e.message??"Runner error"),f(d=>d.map(u=>u.status==="running"?{...u,status:"failed",phase:void 0}:u));break}}})().catch(e=>{if(y.current!==M)return;let u=[e instanceof Error?e.message:String(e)],i=M.stderr;i&&!u.join(`
5
- `).includes(i)&&u.push(i),I(u.join(`
6
- `)),g(!1),f(o=>o.map(t=>t.status==="running"?{...t,status:"failed",phase:void 0}:t)),C("runner","Runner died mid-run"),y.current=null,E.current=null});U.current=L,L.finally(()=>{U.current===L&&(U.current=null)})},[l,n,s,p,v]),ge=(0,h.useCallback)(a=>{y.current?.sendUserResponse(a),T(null)},[]),ve=(0,h.useCallback)(()=>{let a=y.current;a&&(a.cancel(),g(!1),T(null))},[]),Re=(0,h.useCallback)(async()=>{let a=y.current;if(a){try{await Promise.race([a.shutdown(),new Promise(_=>setTimeout(_,5e3))])}catch{}C("runner","Runner shut down"),y.current=null,E.current=null}},[]),Se=(0,h.useCallback)(()=>{f([]),B(null),I(null)},[]);return(0,h.useEffect)(()=>()=>{D.current=!0,C("runner","Component unmounted"),y.current=null,E.current=null},[]),{isRunning:w,steps:x,askingUser:ae,lastRunEnd:ue,runError:de,bifurcationInfo:le,cmInitCounts:ce,replayInfo:pe,maxSteps:he,startRun:me,sendAnswer:ge,cancelRun:ve,shutdownRunner:Re,clearLastRun:Se,getEvidenceState:()=>$.current}}export{A as a,oe as b,_e as c,Ue as d};
@@ -1,2 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as R}from"./chunk-4OPQJ7PE.js";import{y as r}from"./chunk-C4G7RVJ6.js";import{a as Y}from"./chunk-HCBYKLMW.js";import{a,b as i,i as X}from"./chunk-C44QQJR4.js";import{a as G}from"./chunk-6YGTRKDT.js";import{e as P}from"./chunk-UR6MHSHU.js";var u=P(G(),1);var e=P(Y(),1),f=5;function K(t,I){if(!I)return t;let c=I.toLowerCase();return t.filter(B=>B.label.toLowerCase().includes(c))}function J(t){let{title:I,items:c,loading:B=!1,loadingText:F,error:L=null,itemNoun:T="items",onSelect:H,onCancel:E,defaultActiveId:w,onTab:y,extraHint:N}=t,[x,d]=(0,u.useState)(0),[S,g]=(0,u.useState)(0),[s,A]=(0,u.useState)(""),[C,h]=(0,u.useState)(null);(0,u.useEffect)(()=>{if(c.length===0)return;if(t.preserveSelectionById&&C!==null){let n=c.findIndex(o=>o.id===C);if(n>=0){g(Math.floor(n/f)),d(n%f);return}}let l=w?c.findIndex(n=>n.id===w):c.findIndex(n=>n.isActive);l>=0?(g(Math.floor(l/f)),d(l%f),t.preserveSelectionById&&h(c[l].id)):t.preserveSelectionById&&(g(0),d(0),h(c[0]?.id??null))},[c,w,t.preserveSelectionById,C]),(0,u.useEffect)(()=>{if(!t.onSearch)return;let l=setTimeout(()=>t.onSearch(s),t.searchDebounceMs??250);return()=>clearTimeout(l)},[s,t.onSearch,t.searchDebounceMs]);let m=t.onSearch?c:K(c,s),M=S*f,p=Math.min(M+f,m.length),D=Math.ceil(m.length/f),O=p-M,v=m.slice(M,p);return X((l,n)=>{if(L){n.escape&&E();return}if(n.escape){s?(A(""),d(0),g(0)):E();return}if(n.tab&&y){y();return}if(n.upArrow){if(x>0){let o=x-1;d(o),t.preserveSelectionById&&h(v[o]?.id??null)}else if(S>0){let o=S-1,b=f-1;g(o),d(b),t.preserveSelectionById&&h(m[o*f+b]?.id??null)}return}if(n.downArrow){if(x<O-1){let o=x+1;d(o),t.preserveSelectionById&&h(v[o]?.id??null)}else if(S<D-1){let o=S+1,b=0;g(o),d(b),t.preserveSelectionById&&h(m[o*f+b]?.id??null)}return}if(n.return&&v[x]){H(v[x]);return}if(n.backspace||n.delete){A(o=>o.slice(0,-1)),d(0),g(0);return}l&&!n.ctrl&&!n.meta&&(A(o=>o+l),d(0),g(0))},{isActive:!B}),B?(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:r.orange,paddingX:2,paddingY:1,children:[(0,e.jsx)(i,{color:r.orange,bold:!0,children:I}),(0,e.jsx)(a,{marginTop:1,children:(0,e.jsx)(i,{color:r.secondary,children:F??`Loading ${T}\u2026`})})]}):L?(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:r.red,paddingX:2,paddingY:1,children:[(0,e.jsx)(i,{color:r.red,bold:!0,children:I}),(0,e.jsx)(a,{marginTop:1,children:(0,e.jsx)(i,{color:r.red,children:L})}),(0,e.jsx)(R,{bindings:[]})]}):(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:r.orange,paddingX:2,paddingY:1,children:[(0,e.jsxs)(a,{children:[(0,e.jsx)(i,{color:r.orange,bold:!0,children:I}),(0,e.jsxs)(i,{color:r.dim,children:[" (",m.length,!t.onSearch&&s?`/${c.length}`:""," ",T,t.loadingMore?" \xB7 loading more":"",")"]})]}),(0,e.jsxs)(a,{marginTop:1,children:[(0,e.jsx)(i,{color:r.secondary,children:s?"filter: ":""}),s?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(i,{children:s}),(0,e.jsx)(i,{inverse:!0,children:" "})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(i,{color:r.dim,children:["Search ",T,"\u2026"]}),(0,e.jsx)(i,{inverse:!0,children:" "})]})]}),(0,e.jsx)(a,{flexDirection:"column",marginTop:1,children:t.searching?(0,e.jsxs)(i,{color:r.secondary,children:["Searching ",T,"\u2026"]}):m.length===0?(0,e.jsxs)(i,{color:r.dim,children:["No ",T,' match "',s,'"']}):v.map((l,n)=>{let o=n===x,b=o?"\u276F ":" ",$=l.isActive?r.green:o?r.orange:void 0;return(0,e.jsxs)(i,{color:$,children:[b,l.label,l.isActive?" \u25CF selected":""]},l.id)})}),!t.searching&&D>1&&(0,e.jsx)(a,{marginTop:1,children:(0,e.jsxs)(i,{color:r.dim,children:["Page ",S+1,"/",D]})}),t.footer&&(0,e.jsx)(a,{marginTop:1,flexDirection:"column",children:t.footer}),(0,e.jsx)(R,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"type",label:"to search"},{keys:"\u21B5",label:"select"},...y&&N?[{keys:"tab",label:N}]:[]],escBackLabel:s?"clear":"back to chat"})]})}export{J as a};
@@ -1,12 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as Ht}from"./chunk-UPPEOQJQ.js";import{f as Qt}from"./chunk-36OC3TFE.js";import{a as ot,c as Kt,e as Jt,f as Ie,g as Xt,h as sr}from"./chunk-O56PUUNL.js";import{a as Oe,b as jt,c as Bt,d as Ft,e as qt}from"./chunk-NRC2G4Y5.js";import{a as zt,b as Zt,c as er,d as tr,e as at,f as rr}from"./chunk-2XGDWUJ5.js";import{a as Gt}from"./chunk-L2TV4G56.js";import{a as Wt,b as Vt}from"./chunk-JFAFKHDX.js";import{c as Lt}from"./chunk-5KFS3GAZ.js";import{d as It}from"./chunk-UX2B7L6K.js";import{a as Ae}from"./chunk-XDHZMCTA.js";import{a as Mt,e as Nt}from"./chunk-AAONIIQV.js";import{b as Ut}from"./chunk-YKTYVJBN.js";import{a as Yt}from"./chunk-CVOGP253.js";import{c as Ot}from"./chunk-SE6WNCYU.js";import{a as fe,b as nt}from"./chunk-DNNZ353O.js";import{b as it}from"./chunk-GVIPTX6T.js";import{a as he}from"./chunk-NVGBE2DR.js";import{a as z}from"./chunk-GW5DWAXY.js";import{j as ge,n as st}from"./chunk-3STZLM5J.js";import{f as At}from"./chunk-M7WQM4UA.js";import{e as rt}from"./chunk-WWNSD6FA.js";import{b as Tt}from"./chunk-IAHKTEET.js";import{d as ne}from"./chunk-5YPBPZUR.js";import{a as Pt}from"./chunk-5EOX4MEY.js";import{appendFileSync as vr,mkdirSync as ct,rmdirSync as wr,writeFileSync as dt}from"fs";import{dirname as dr,extname as br,join as ee}from"path";var W=class extends Error{code;constructor(e,c){super(`${e}: ${c}`),this.name="ProposalAdapterError",this.code=e}};function nr(r){return r.version===2}var ir=8;function xr(r){let e=/^extract@(\d+)$/.exec(r??"");return e?Number.parseInt(e[1],10):null}var yr=r=>typeof r=="object"&&r!==null&&"op"in r;function Me(r,e,c){return{anchor:r.anchor,quote:r.quote,...c||r.source_id!==e?{source_id:r.source_id}:{}}}function or(r,e,c={}){let l=xr(c.templateVersion),f=l!==null&&l>=5,_=l!==null&&l<5;if(!f&&r.read_basis.length!==1)throw new W("READ_BASIS_COUNT",`read_basis must have exactly 1 element, got ${r.read_basis.length}`);if(r.read_basis.length===0)throw new W("READ_BASIS_COUNT","read_basis must not be empty");let h=r.read_basis[0],$=r.read_basis.length>1,g=r.use_cases.map(i=>{if(_&&i.cite.length!==1)throw new W("CITE_COUNT",`${i.temp_ref}: cite must have exactly 1 element, got ${i.cite.length}`);if(i.cite.length<1||i.cite.length>ir)throw new W("CITE_COUNT",`${i.temp_ref}: 1..${ir} cites allowed, got ${i.cite.length}`);let k=(n,D)=>{if(!f&&n!==h.source_id)throw new W("SOURCE_MISMATCH",`${D}: cite source ${n} != read_basis source ${h.source_id} (single-source)`)};k(i.cite[0].source_id,i.temp_ref);let O=i.cite.map(n=>(k(n.source_id,i.temp_ref),Me(n,h.source_id,f&&($||n.source_id!==h.source_id)))),A=(i.updated?.criteria??[]).some(yr);if(!f&&A)throw new W("CRITERIA_OPS_UNSUPPORTED",`${i.temp_ref}: op-union updated.criteria (keep/set/remove) needs an extract@5+ binding \u2014 this session is bound to ${c.templateVersion??"an unversioned template"}`);return{temp_ref:i.temp_ref,title:i.title,...i.description!==void 0?{description:i.description}:{},...i.summary!==void 0?{summary:i.summary}:{},...i.actors!==void 0?{actors:i.actors}:{},...i.value!==void 0?{value:i.value}:{},risk:i.risk,cite:O[0],...O.length>1?{cites:O}:{},...i.criteria!=null&&i.criteria.length>0?{criteria:i.criteria.map((n,D)=>(k(n.cite.source_id,`${i.temp_ref}.criteria[${D}]`),{text:n.text,cite:Me(n.cite,h.source_id,f&&n.cite.source_id!==h.source_id)}))}:{},depends_on_hint:i.depends_on_hint,matches_existing:i.matches_existing,...i.conflicts_with!=null?{conflicts_with:i.conflicts_with}:{},...i.changed?{changed:!0}:{},...i.updated!=null?{updated:{...i.updated.title!=null?{title:i.updated.title}:{},...i.updated.description!=null?{description:i.updated.description}:{},...i.updated.summary!=null?{summary:i.updated.summary}:{},...i.updated.actors!=null?{actors:i.updated.actors}:{},...i.updated.value!=null?{value:i.updated.value}:{},...i.updated.risk!=null?{risk:i.updated.risk}:{},...i.updated.criteria!=null?{criteria:A?i.updated.criteria.map(n=>n.op==="set"?{op:"set",text:n.text,cite:Me(n.cite,h.source_id,f&&n.cite.source_id!==h.source_id)}:n.op==="keep"?{op:"keep",ref:n.ref,text:n.text}:{op:"remove",ref:n.ref,text:n.text,reason:n.reason}):i.updated.criteria.map((n,D)=>(k(n.cite.source_id,`${i.temp_ref}.updated.criteria[${D}]`),{text:n.text,cite:Me(n.cite,h.source_id,f&&n.cite.source_id!==h.source_id)}))}:{}}}:{},...i.change_note!=null?{change_note:i.change_note}:{}}});return{version:1,read_basis:e,source:{source_id:h.source_id,source_cid:h.source_cid},use_cases:g,...$?{sources:r.read_basis.map(i=>({source_id:i.source_id,source_cid:i.source_cid}))}:{},...r.extraction_of!=null&&r.extraction_of.length>0?{extraction_claims:r.extraction_of.map(i=>({source_id:i.source_id,completeness:i.completeness}))}:{}}}function ar(r){let{contextDir:e,graph:c}=r,l=r.maxDigestBytes??4096,f={},_=[];for(let[g,i]of c.heads){if(f[g]=i,typeof i!="string")continue;let k=c.mediaOf(i),O=c.getNode(i)?.content?.blob;if(typeof O=="string")if(k.format==="image")_.push({source_id:g,cid:i,format:"image",blobRef:{path:he(e,O),cid:O}});else{let A=fe(e,c,i)?.toString("utf8")??"";_.push({source_id:g,cid:i,format:k.format,text:A})}}_.sort((g,i)=>g.source_id<i.source_id?-1:1);let h=[];for(let g of c.byLabel(ne.STYLENOTE).sort((i,k)=>i.cid<k.cid?-1:1))c.superseded.has(g.cid)||h.push(`\u2022 ${String(g.content.statement)} [${String(g.content.learned_from_kind)}]`);let $="";for(let g of h){if(Buffer.byteLength($+g+`
3
- `,"utf8")>l)break;$+=g+`
4
- `}return{read_basis:f,sources:_,styleNoteDigest:$}}function cr(r,e){let c=ar({contextDir:r,graph:e}).styleNoteDigest;return c.length>0?c:void 0}function ur(r,e,c,l,f){let _=null,h=()=>_??=f&&Object.keys(f).length>0?Promise.resolve(f):It().catch(()=>({}));return{contextDir:r,rootSid:e,locks:rt(r,e),probe:l??Ht(r,{resolveAlias:async $=>jt($,{env:process.env,auth:await h()}),embed:async($,g)=>Bt($,g,{env:process.env,auth:await h()}),readVector:($,g)=>Ft(r,$,g),writeVector:($,g,i)=>qt(r,$,g,i)}),...c?.length?{reservedEventIds:c}:{}}}function lr(r,e){let c=[],l=[];for(let f of r.use_cases){let _=f.matches_existing;_?.cid&&e.hasNode(_.cid)?c.push({ref:_.cid,expectedTip:e.tipOf(_.cid)}):l.push({tempRef:f.temp_ref,title:String(f.title??""),probeText:String(f.title??"")})}return{verb:"extract",ucTargets:c,newBuCandidates:l,sourcePins:[{source_id:r.source.source_id,source_cid:r.source.source_cid}],readBasis:r.read_basis??null}}function kr(r,e){let c=(r.images??[]).filter(l=>l.delivery==="selected");if(c.length!==0)return c.map(l=>({ref:l.ref,...l.page!==void 0?{page:l.page}:{},...l.loc!==void 0?{loc:l.loc}:{},media_type:l.media_type,blob_ref:{path:he(e,l.blob),cid:l.blob}}))}function Sr(r){return r.length>8&&r[0]===137&&r[1]===80&&r[2]===78&&r[3]===71?"image/png":r.length>3&&r[0]===255&&r[1]===216&&r[2]===255?"image/jpeg":r.length>12&&r.toString("ascii",0,4)==="RIFF"&&r.toString("ascii",8,12)==="WEBP"?"image/webp":null}function Ne(r){return r.toISOString().replace(/[-:]/g,"").slice(0,15)}function mr(r){return r.startsWith("su-conv-")?`conv-${Tt(Buffer.from(r,"utf8")).slice(0,8)}`:r}function fr(r){return r.source_id.startsWith("su-conv-")?"the conversation":r.source_id}function $r(r,e,c){return`reading ${fr(r)}${c>1?` (source ${e} of ${c})`:""}`}function pe(r){return r.toLowerCase().trim().replace(/\s+/g," ")}function gr(r,e){let c=new Map,l=new Map,f=new Map;for(let{cid:h,content:$}of e.byLabel(ne.USECASE)){if(e.superseded.has(h))continue;(e.trust.get(h)==="archived"?f:l).set(pe(String($.title??"")),h)}let _=h=>e.trust.get(h)==="archived"?{cid:h,archived:!0,reason:e.archivedReason.get(h)}:{cid:h};for(let h of r.use_cases){if(h.matches_existing){let i=h.matches_existing.cid;if(e.superseded.has(i)){let k=e.tipOf(i);i=e.superseded.has(k)?null:k}if(i!==null){c.set(h.temp_ref,_(i));continue}}let $=l.get(pe(h.title));if($){c.set(h.temp_ref,{cid:$});continue}let g=f.get(pe(h.title));g&&c.set(h.temp_ref,_(g))}return c}var hr=/^(\S+)\.criteria\[(\d+)\]/;function Cr(r,e,c){if(e.length===0||!e.every(f=>hr.test(f.detail)))return!1;let l=new Map;for(let f of e){let _=hr.exec(f.detail),h=l.get(_[1])??new Set;h.add(Number(_[2])),l.set(_[1],h)}for(let f of r.use_cases){let _=l.get(f.temp_ref);_?.size&&(f.criteria=(f.criteria??[]).filter((h,$)=>!_.has($)),c(`${f.temp_ref}: dropped ${_.size} criteria with unverifiable cites \u2014 committed without them (criteria are hints, not oracles)`))}return!0}async function ut(r,e,c,l,f=()=>{},_,h){let $=(g,i)=>f(g,i,r.session_id);return Jt(r,e,c,l,f,{async onProposalEvent(g){let i=g,k=null,O=null;if(nr(i))try{k=or(i,r.read_basis,{templateVersion:h?.()??null}),$("adapter",{ok:!0,use_cases:k.use_cases.length})}catch(A){O=A instanceof W?A.message:String(A),$("adapter",{ok:!1,error:O})}else k=i;return k&&k.use_cases.length===0&&e.out("warning: the agent proposed ZERO use-cases for this source"),k&&_&&await _(k),{proposal:k,error:O}}})}var Rr=new Set(["agent","ci","override"]);async function ws(r,e){let c=`ext-${Ne(e.now?.()??new Date)}-lk${Math.random().toString(36).slice(2,8)}`,f=rt(e.contextDir,c,e.now?{now:e.now}:void 0).tryAcquire([{kind:"extract"}],{hold:"session",verb:"extract"});if("contended"in f){let _=f.contended.holder,h=`another extraction is running on this context${_?` (pid ${_.pid})`:""} \u2014 retry when it finishes`;return e.out(h),e.emit?.({type:"error",message:h,code:"EXTRACT_LOCKED"}),2}try{return await Dr(r,e)}finally{f.release()}}async function Dr(r,e){let c=r.mode??"interactive";if(r.trust==="hold"&&c==="interactive")return e.out("error: --trust hold only applies to headless runs \u2014 in interactive chat you review items in-session anyway; use --mode agent to hold everything for review"),e.emit?.({type:"error",message:"error: --trust hold only applies to headless runs \u2014 use --mode agent",code:"TRUST_USAGE"}),2;if(c==="interactive"){if(!e.isTTY)return e.out("extract: --mode interactive needs a TTY (use --mode agent|ci|override headless)"),2}else if(!Rr.has(c))return e.out(`extract: unknown mode "${c}" \u2014 interactive | agent | ci | override`),2;if(r.trust!==void 0){if(c==="ci")return e.out("error: --trust is not available under --mode ci (ci is fail-closed \u2014 no trust dials)"),e.emit?.({type:"error",message:"error: --trust is not available under --mode ci",code:"TRUST_UNDER_CI"}),2;if(r.trust!=="auto"&&r.trust!=="hold")return e.out(`error: --trust must be auto | hold, got '${r.trust}'`),e.emit?.({type:"error",message:`error: --trust must be auto | hold, got '${r.trust}'`,code:"TRUST_USAGE"}),2}let l=e.telemetry?.enabled?e.telemetry:void 0,f=Ne(e.now?.()??new Date),_=l?Pt(l.ids.context_instance_id??null,"extract",l.ids.session_id):ee(e.contextDir,"logs",`extract-${f}.log`);ct(dr(_),{recursive:!0});let h=`run-${f}-${Math.random().toString(36).slice(2,8)}`,$=a=>a==="error"||a==="failed_proposal"?"error":a==="repair_respawn"?"warn":"info",g=(a,u,s)=>{try{vr(_,JSON.stringify({ts:new Date().toISOString(),level:$(a),run_id:h,...l?{user_session_id:l.ids.session_id}:{},...s?{session_id:s}:{},kind:a,data:u})+`
5
- `)}catch{}l?.wireTrace(a,u,s)};e.out(`trace: ${ot(_)}`),l&&e.out(l.banner()),e.emit?.({type:"run_start",mode:c,trace:_});let i=Ut();if(i&&e.out(i),e.preflightTurn){let a=await e.preflightTurn();if(g("preflight",a),!a.ok)return e.out(a.message??"error: turn-endpoint preflight failed"),e.emit?.({type:"error",message:a.message??"error: turn-endpoint preflight failed",code:"PREFLIGHT"}),2}let k=z(e.contextDir),O=cr(e.contextDir,k),A=r.sources?.length?r.sources:r.source?[r.source]:[];if(A.length>0){if(r.resume){let a="error: --source cannot be combined with --resume (the resumed session already has its scope)";return e.out(a),e.emit?.({type:"error",message:a,code:"SOURCE_WITH_RESUME"}),2}for(let a of A){let u=k.heads.get(a);if(typeof u!="string"){let s=u===null?`error: --source ${a} was ingested but is retired \u2014 re-ingest it to extract again`:`error: --source ${a} is not an ingested source (kane-cli context list shows them)`;return e.out(s),e.emit?.({type:"error",message:s,code:"SOURCE_UNKNOWN"}),2}}}let n=null,D=null;if(r.resume){try{{let d=await rr(e.contextDir,r.resume,k,{verb:"extract",deps:{onWarn:b=>e.out(`note: ${b}`)}});{let b=Object.keys(d.handle.state.read_basis??{});if(b.length>1){let N=`error: session ${r.resume} spans ${b.length} sources \u2014 multi-source resume isn't supported yet; committed work is preserved (re-run kane-cli context extract for anything remaining)`;return e.out(N),e.emit?.({type:"error",message:N,code:"MULTI_SOURCE_RESUME"}),d.handle.release(),2}D=d,g("resume_kind",{kind:d.view.pointer===null?"bare-base":d.view.pointer.at==="final"?"pause":"crash"}),n={handle:d.handle,represent:d.represent,questions:d.questions,staleBasis:d.drift.map(N=>N.subject)}}}}catch(d){let b=d instanceof Error?d.message:String(d);return e.out(`error: ${b}`),e.emit?.({type:"error",message:`error: ${b}`,...d instanceof at?{code:d.code}:{}}),d instanceof at?2:1}let a=D?null:zt(n.handle.state.verb,"extract",r.resume);if(a)return e.out(a.message),e.emit?.({type:"error",message:a.message,code:a.code}),n.handle.release(),2;let u=n.handle.state.change_basis;if(u&&(k.heads.get(u.source_id)??null)!==u.new_head){let d=`error: ${u.source_id} moved while this reconcile extraction was paused \u2014 its recorded change context no longer matches; re-run kane-cli maintain reconcile against the current file (session ${r.resume} is defunct and can be ignored)`;return e.out(d),e.emit?.({type:"error",message:d,code:"CHANGE_BASIS_MOVED"}),n.handle.release(),2}if(D&&D.view.pointer!==null&&D.drift.length>0){if(!await e.confirmStale(`changed since the pause: ${D.drift.map(b=>b.subject).join(", ")} \u2014 re-ground and continue against the current versions?`)){let b=`resume aborted: the context moved since the pause (${D.drift.map(N=>N.subject).join(", ")}) \u2014 session ${r.resume} is preserved`;return e.out(b),e.emit?.({type:"error",message:b,code:"RESUME_DRIFT"}),n.handle.release(),2}}else n.staleBasis.length>0&&e.out(`note: changed since the pause: ${n.staleBasis.join(", ")} \u2014 re-presented items may be stale`);let s=[...new Set([...n.handle.state.held_receipts??[],...D?.view.kane?.held_receipts??[]])];if(s.length>0)if(e.chat?.holdReceipt)for(let d of s)e.chat.holdReceipt(d);else e={...e,initialMessage:[s.join(`
6
-
7
- `),e.initialMessage].filter(Boolean).join(`
8
-
9
- `)};n.handle.state.assumed.length>0&&e.out(`note: ${n.handle.state.assumed.length} default(s) were assumed while you were away \u2014 kane-cli context sessions show ${r.resume} lists them`)}let lt=k.extractedSourceCids,oe=!!(r.force||n?.handle.state.force),K=[],X=[],_e=A.length>0?new Set(A):null;for(let[a,u]of k.heads.entries())if(u!=null&&!(_e&&!_e.has(a))){if(!_e&&!n&&a.startsWith("su-conv-")){e.out(`skipped ${a} \u2014 conversation source; extract it explicitly with --source ${a}`),X.push({source_id:a,reason:"conversation"});continue}if(n){let s=a in n.handle.state.read_basis,d=n.handle.state.corpus_cursor.remaining.includes(a);if(!s&&!d)continue;if(d&&!oe&&lt.has(u)){e.out(`${a} already extracted \u2014 skipped (--force re-runs it)`),X.push({source_id:a,reason:"cached"});continue}}else if(!oe&&lt.has(u)){e.out(`${a} already extracted \u2014 skipped (--force re-runs it)`),X.push({source_id:a,reason:"cached"});continue}K.push({source_id:a,cid:u})}let pr=a=>{let u=Qt(e.contextDir,a);u&&e.out(`note: a reconcile plan for ${a} is pending (${u.pending} item(s)) \u2014 resume with \`kane-cli maintain reconcile --apply ${u.path}\``)};for(let a of X)a.reason==="cached"&&pr(a.source_id);if(e.emit?.({type:"corpus",sources:K,skipped:X}),K.length===0){if(n){let s=`error: resumed session's paused source (${Object.keys(n.handle.state.read_basis).join(", ")||"unknown"}) is no longer in the corpus \u2014 restore/re-ingest it and re-run --resume ${r.resume}, or discard with: kane-cli context sessions clean ${r.resume}`;return e.out(s),e.emit?.({type:"error",message:s,code:"SOURCE_MISSING"}),n.handle.release(),2}let a=X.length>0&&X.every(u=>u.reason==="conversation");return e.out(_e?`extract: nothing to do \u2014 ${A.join(", ")} ${A.length===1?"is":"are all"} already extracted at the current snapshot (--force to re-run)`:a?"extract: nothing to do \u2014 only conversation sources here (extract one explicitly with --source <id>)":"extract: nothing to do \u2014 every ingested source is already extracted"),0}let Y=!r.plan&&c!=="ci",xe=e.now?.()??new Date,ye=r.resume??`ext-${Ne(xe)}-${mr(K[0].source_id)}`,P=null,ve=!1;Y&&!n&&(P=it(e.contextDir,{sid:ye,mode:"agent",created_at:xe.toISOString(),expires_at:new Date(xe.getTime()+1440*60*1e3).toISOString(),agent_state:{schema:2,items:[],provider_state:""},pending:{questions:[],proposals:[]},assumed:[],read_basis:{[K[0].source_id]:K[0].cid},corpus_cursor:{remaining:K.slice(1).map(a=>a.source_id)},conv_source:"",verb:"extract",...oe?{force:!0}:{},...r.changeContext?{change_basis:{source_id:r.changeContext.source_id,new_head:r.changeContext.new_head}}:{},...l?{user_session_id:l.ids.session_id}:{}}));let mt=D?D.represent.map(a=>a.event_id).filter(a=>typeof a=="string"):[],y=n?.handle??P,gt=!1,ht=()=>{try{wr(ee(e.contextDir,"sessions"))}catch{}},ft=()=>{if(P){try{P.complete()}catch{P.release()}P=null,y=null,ht()}},we=new Map;if(n&&n.questions.length>0&&!r.message&&!r.withSource){e.out(`re-presenting ${n.questions.length} unanswered question(s) from the paused session`);let a=await e.ask(n.questions.map(Zt));if(Array.isArray(a))for(let u of a)we.set(u.id,u)}let be=e.by??{kind:"human",id:"owner"},J=c==="interactive"&&!r.plan&&!!e.chat,He=0,pt=0,ke=!1,Se=0,Ue=()=>{ke||(ke=!0,e.out("note: duplicate detection is running in a reduced mode this run \u2014 new items will be held for your review instead of committed"),l?.event("ASR_EMBED_DEGRADED",{}),e.emit?.({type:"degraded",reason:"embed_fallback"}))},je=null,$e=()=>y??P,Be=(a,u,s)=>{let d=$e();if(!d)return;let b=u.map(v=>({label:"usecase",content:{title:v.title,...v.summary!==void 0?{summary:v.summary}:{},...v.risk!==void 0?{risk:v.risk}:{},derived:!0,_held:{source_id:a.source_id,source_cid:a.cid,anchor:v.cite?.anchor??"L1-L1",quote:v.cite?.quote??""}},rationale:`held (${s==="degraded"?"embed degraded \u2014 lexical dedup only":"--trust hold"}): ${a.source_id} @ ${a.cid.slice(0,19)} ${v.cite?.anchor??""}`,edges:[],tempRef:v.temp_ref})),N=d.state.pending;d.save({pending:{questions:N.questions,proposals:[...N.proposals,...b]}}),Se+=b.length,je=d.state.sid,e.out(`held: ${b.length} item(s) from ${a.source_id} \u2014 ${s==="degraded"?"duplicate detection was reduced this run":"--trust hold"}; nothing committed for this source (review them at resume)`),e.emit?.({type:"held",source_id:a.source_id,count:b.length,reason:s==="degraded"?"embed_degraded":"trust_hold"})},U=[],_t=!1,I=[...K];try{let a=u=>{let s=y;if(!s)return;let d=s.state.ingest_schedule??[];if(!d.some(v=>v.status==="pending"))return;let b=z(e.contextDir),N=d.map(v=>v.status!=="pending"?v:(b.heads.get(v.source_id)??null)!==v.cid?(e.out(`note: ${v.source_id} changed after it was added \u2014 skipping its extraction this run; re-run kane-cli context extract to pick up the newer version`),{...v,status:"skipped",note:"head moved since landing"}):b.extractedSourceCids.has(v.cid)||I.some(F=>F.source_id===v.source_id&&F.cid===v.cid)?{...v,status:"done"}:I.some(F=>F.source_id===v.source_id)?(e.out(`note: an older version of ${v.source_id} is already queued this run \u2014 the newly landed version is not extracted; re-run kane-cli context extract to pick it up`),{...v,status:"skipped",note:"an older version of the source was already queued this run"}):(I.push({source_id:v.source_id,cid:v.cid}),e.out(`queued ${v.source_id} for extraction in this run (landed mid-run)`),{...v,status:"done"}));s.save({ingest_schedule:N,corpus_cursor:{remaining:I.slice(u+1).map(v=>v.source_id)}})};for(let u=0;u<I.length;a(u),u++){let s=I[u],d=z(e.contextDir),b={current:d};e.chat?.attachOnCommitted?.(t=>{b.current=t});let N=d.getNode(s.cid),v=String(N?.content.blob??""),Ce=fe(e.contextDir,d,s.cid);if(!Ce){e.out(`error: ${s.source_id}: its stored content is missing \u2014 re-ingest the file (kane-cli context ingest <file>) [BLOB_MISSING]`),e.emit?.({type:"error",source_id:s.source_id,message:`error: ${s.source_id}: blob ${v} missing from .context/blobs`,code:"BLOB_MISSING"}),U.push(s.source_id);continue}let F=d.mediaOf(s.cid),Fe=F.media_type.startsWith("image/");if(!Fe){let t=Sr(Ce);if(t){e.out(`skipping ${s.source_id}: binary ${t} ingested before image support \u2014 re-ingest it (kane-cli context ingest) to extract from it`),e.emit?.({type:"source_skipped",source_id:s.source_id,reason:"binary_pre_media"});continue}}let xt=Fe?`0001| (image source ${s.source_id} \u2014 the content is attached as an image; cite it with anchor img#whole)`:nt(Ce),Re=(t,o)=>{let m=new Map;m.set(s.source_id,{media:F,numberedText:xt});for(let p of o.sources??[]){if(m.has(p.source_id))continue;let E=fe(e.contextDir,t,p.source_cid);if(!E)continue;let S=t.mediaOf(p.source_cid),R=S.media_type.startsWith("image/")?`0001| (image source ${p.source_id} \u2014 the content is attached as an image; cite it with anchor img#whole)`:nt(E);m.set(p.source_id,{media:S,numberedText:R})}return m},yt=Ne(e.now?.()??new Date),ae=`${yt}-${s.source_id}`,ce=!!(n&&s.source_id in n.handle.state.read_basis),De=y?ye:`ext-${yt}-${mr(s.source_id)}`,qe=I.slice(u+1).map(t=>t.source_id);y&&Y&&!ce&&y.save({read_basis:{[s.source_id]:s.cid},corpus_cursor:{remaining:qe}});let Q="";if(J){let t=Lt({contextDir:e.contextDir,graph:z(e.contextDir),sessionStamp:De,by:be});t.errors===null||t.errors[0]?.code==="CONV_SOURCE_EXISTS"?(Q=t.sourceId,e.chat.attachConversationSource?.(Q),b.current=z(e.contextDir)):e.out(`warning: notes you add in chat can't be saved to the context this session (${t.errors[0]?.detail})`)}let vt={type:"run_config",version:1,session_id:De,mode:c,source:{source_id:s.source_id,source_cid:s.cid,kind:Ot.has(F.format)?F.format:br(s.source_id)||"md",numbered_text:xt,...(()=>{let t=kr(F,e.contextDir);return t?{images:t}:{}})()},existing_use_cases:d.byLabel(ne.USECASE).filter(({cid:t})=>d.trust.get(t)!=="archived"&&!d.superseded.has(t)).map(({cid:t,content:o})=>({id:t,title:String(o.title??""),summary:String(o.summary??"")})),read_basis:b.current.latestHash,max_free_text_rounds:Kt,graph_reads:!0,verb:"extract",...O!==void 0?{style_note_digest:O}:{},...r.changeContext&&r.changeContext.source_id===s.source_id?{change_context:r.changeContext}:{},topology:Yt(),...J?{chat:!0}:{},...Fe?{image_sources:[{source_id:s.source_id,source_cid:s.cid,media_type:F.media_type,blob_ref:{path:he(e.contextDir,v),cid:v}}]}:{},...n&&!D&&s.source_id in n.handle.state.read_basis?{resume:{agent_state:n.handle.state.agent_state}}:{},...Y&&y?{checkpoints:!0}:{}},C=D&&ce?{...D.spawnConfig,mode:c}:vt;if(Y&&y&&!gt){gt=!0;let{resume:t,...o}=vt;Nt(e.contextDir,ye,{schema:Mt,kind:"base",sid:ye,verb:"extract",mode:c,created_at:xe.toISOString(),run_config:o,conv_source:Q||y.state.conv_source||"",store_watermark:At(e.contextDir)})}let wt=D&&ce?0:y?.state.checkpoint?.seq??0,de={current:null};if(C.resume&&"schema"in C.resume){let t=C.resume.binding?.template_version;typeof t=="string"&&(de.current=t)}let Le=Y&&y?tr({contextDir:e.contextDir,handle:y,seqBase:()=>wt,peekHeldReceipts:()=>e.chat?.peekHeldReceipts?.()??[],readBasis:()=>({[s.source_id]:s.cid}),corpusCursor:()=>({remaining:qe}),onSoftCap:t=>e.out(t),onStat:t=>g("ckpt_stat",t,C.session_id),...e.now?{now:e.now}:{}}):void 0,te=Le?{...Le,persist:t=>{let o=t.binding?.template_version;return typeof o=="string"&&o&&(de.current=o),Le.persist(t)}}:void 0;J||e.out(n&&s.source_id in n.handle.state.read_basis?`resuming: ${s.source_id} (session ${r.resume})`:`extracting: ${s.source_id} @ ${s.cid.slice(0,19)}`),e.emit?.({type:"source_start",source_id:s.source_id,cid:s.cid,index:u+1,total:I.length,resumed:!!(n&&s.source_id in n.handle.state.read_basis)}),e.chat?.ledger?.({kind:"banner",text:$r(s,u+1,I.length)}),e.chat?.setWorking?.(`Reading ${fr(s)}\u2026`);let Ge=new Map;g("spawn",{source_id:s.source_id,source_cid:s.cid,resume:!!n,chat:J},C.session_id);let bt=!1,kt=!1,We=!1,St=async t=>{let o=z(e.contextDir),m=ge(t,Re(o,t),o);if(g("kane_validate",{errors:m.map(x=>x.code)},C.session_id),m.length>0){if(e.nested){e.chat?.ledger?.({kind:"commit",ok:!1,line:"proposal failed validation \u2014 nothing landed",warnings:m.map(x=>`${x.code}: ${x.detail}`)}),kt=!0;return}e.chat.submit("[auto-repair] the proposal failed validation: "+m.map(x=>`${x.code}: ${x.detail}`).join("; ")+" \u2014 please re-finalize with these fixed.");return}let p=z(e.contextDir),E=gr(t,p),S=ee(e.contextDir,"proposals",ae);ct(S,{recursive:!0}),dt(ee(S,"proposal.json"),JSON.stringify(t,null,2)+`
10
- `);let R=new Map(t.use_cases.map(x=>[x.temp_ref,{resolution:"skipped"}])),ue=ur(e.contextDir,C.session_id,mt,e.probe,e.auth),B=await Oe(ue,lr(t,p),x=>{if(x.degradedProbe&&$e()!==null&&t.use_cases.some(le=>le.matches_existing==null))return{result:{degradedHold:!0},record:null};let L=st({contextDir:e.contextDir,graph:x.graph,proposal:t,proposalId:ae,verdicts:R,by:{kind:"ai",id:"extract-agent"},autoName:!0,allowStaleBasis:!0,eventIds:x.eventIds("extract",1),...Y?{sid:x.sid}:{},probeHits:x.probeHits});return L.errors!==null?{errors:L.errors}:{result:L,record:L.record}}),tt=B.ok&&"result"in B?B.result:null;if(tt!==null&&"degradedHold"in tt){Ue(),Be(s,t.use_cases,"degraded"),We=!0,e.chat.ledger?.({kind:"commit",ok:!1,line:`held ${t.use_cases.length} item(s) for review \u2014 semantic dedup ran degraded (embeddings unavailable); nothing saved this turn`});return}let Z=tt??{record:null,errors:B.ok?null:B.kind==="validation"?B.errors:[{code:B.kind==="contended"?B.err.code:"UNSETTLED",detail:B.kind==="contended"?`held by ${B.err.holder?.owner_sid??"another session"}`:"concurrent activity kept moving the store"}]};if(Z.errors){e.chat.ledger?.({kind:"commit",ok:!1,line:"commit failed \u2014 nothing landed",warnings:Z.errors.map(x=>`${x.code}: ${x.detail}`)});return}bt=!0,Z.record?.event_ids?.length&&y?.markApplied(Z.record.event_ids);{let x=Z.record.review.filter(L=>L.kind==="pending_update");x.length>0&&(e.out(`${x.length} update(s) held for review`),e.emit?.({type:"update_held",count:x.length,targets:x.map(L=>L.id)}),e.chat?.ledger?.({kind:"commit",ok:!0,line:`${x.length} update(s) held for review`}))}let se=Z.record.nodes.length;He+=se;let ie=t.use_cases.length-se;{let x=z(e.contextDir),L=new Map;for(let{cid:M,content:G}of x.byLabel(ne.USECASE))x.superseded.has(M)||L.set(pe(String(G.title??"")),M);let le=[];for(let M of t.use_cases){let G=null;if(M.matches_existing?.cid&&x.hasNode(M.matches_existing.cid)){let me=x.tipOf(M.matches_existing.cid);G=x.superseded.has(me)?null:me}G=G??L.get(pe(M.title))??null,G&&le.push({ref:M.temp_ref,cid:G,...x.displayNameOf(G)?{id:x.displayNameOf(G)}:{}})}le.length>0&&e.chat.registerAliases?.(le),b.current=x;let Dt=M=>{for(let[G,me]of x.names)if(me===M&&!x.superseded.has(me))return G},Et=Gt({verb:"extract",commitN:1,phase:"proposal",committed:Z.record.nodes.map(M=>({cid:M.cid,...Dt(M.cid)?{logical_id:Dt(M.cid)}:{}})),reused:ie},x);e.emit?.(Et.event),e.chat.holdReceipt?.(Et.text)}g("commit",{derived:se,evidence_matched:ie,chat:!0},C.session_id),e.chat.ledger?.({kind:"commit",ok:!0,line:se===0&&ie>0?`all ${ie} matched existing \u2014 nothing new to save`:`saved ${se} use-case${se===1?"":"s"} as drafts`+(ie>0?` \xB7 ${ie} matched existing`:"")})},Ve=!!(n&&s.source_id in n.handle.state.read_basis),j=Ve&&we.size>0?{...e,ask:async t=>t.every(o=>we.has(o.id))?(n.handle.markApplied(t.map(o=>`resolveq:${r.resume}:${o.id}`)),e.out(`answered ${t.length} re-asked question(s) from the held resume answers`),t.map(o=>we.get(o.id))):e.ask(t)}:e;Ve&&r.message&&(j={...j,initialMessage:r.message}),j={...j,onEmbedDegraded:Ue};let re,ze;if(y){let t=y,o=j.ask,m=Xt({contextDir:e.contextDir,cwd:dr(e.contextDir),handle:t,note:p=>e.chat?e.chat.note(p):e.out(p),schedule:r.trust!=="hold",...r.trust==="hold"?{scheduleRefused:"this run holds items for review, so its extraction is not scheduled \u2014 kane-cli context extract runs it after the review"}:{},graphSlot:b,...e.now?{now:e.now}:{}});if(j={...j,ask:async p=>{let E=await o(p);if(Array.isArray(E)){let S=E.filter(R=>{if(R.free_text==null||R.free_text.trim()==="")return!1;let ue=p.find(B=>B.id===R.id);return R.selected_index!=null&&ue?.options[R.selected_index]?.input===!0}).map(R=>R.free_text.trim());if(S.length>0){let R=t.state.ingest_registry;for(let ue of S)R=Ie(R,ue,e.now?.()??new Date);t.save({ingest_registry:R})}}return E},ingest:m},Ve&&r.withSource){let p=(t.state.pending?.proposals??[]).filter(R=>R.content?._held!=null).length;if(r.trust==="hold"||p>0){let R=p>0?`error: --with-source can't add a source to a session holding ${p} item(s) for review \u2014 resume without --with-source to finish the review first, then land it with kane-cli context ingest [HOLD_MULTI_SOURCE]`:"error: --with-source is not available with --trust hold \u2014 held work from a multi-source run can't be resumed yet; drop --trust hold, or land the source separately with kane-cli context ingest [HOLD_MULTI_SOURCE]";return e.out(R),e.emit?.({type:"error",code:"HOLD_MULTI_SOURCE",message:R}),2}let E=r.withSource;t.save({ingest_registry:Ie(t.state.ingest_registry,E,e.now?.()??new Date)});let S=await m({id:`withsource-${t.state.sid}`,ref:E,purpose:null});if(!S.ok)return e.out(`error: --with-source: ${S.error.message}`),e.emit?.({type:"error",code:S.error.code,message:`--with-source: ${S.error.message}`}),2;j={...j,pendingDeferral:{ingested:{source_id:S.result.source_id,cid:S.result.cid}}}}ze=()=>{if(!e.chat?.attachIngest)return;let p=e.chat;re=p.attachIngest(async E=>{try{t.save({ingest_registry:Ie(t.state.ingest_registry,E,e.now?.()??new Date)});let S=await m({id:`attach-${t.state.sid}-${(t.state.ingest_registry??[]).length}`,ref:E,purpose:null});return S.ok?(p.deferBatch({source_id:S.result.source_id,cid:S.result.cid}),{ok:!0}):{ok:!1,error:S.error.message}}catch(S){return{ok:!1,error:S instanceof Error?S.message:String(S)}}})},ze()}let w;try{w=await ut(C,{...j,graphSlot:b,...te?{checkpoint:te}:{}},Ge,d,g,J?St:void 0,()=>de.current)}catch(t){if(t instanceof Ae)return re?.(),e.chat?.setWorking?.(null),e.out(`error: ${t.message}`),e.emit?.({type:"error",code:"PAIR_MISMATCH",message:t.message}),2;throw t}if(re?.(),e.chat?.setWorking?.(null),w.errorCode==="binding_mismatch"&&D&&ce){let t=await e.ask([{id:"binding-mismatch",text:"this session's saved conversation is no longer accepted by the service \u2014 start the conversation fresh (committed work is kept), or stop and keep the session?",risk:"high",rationale:"the service refused the saved conversation on the first turn after resume",options:[{label:"start fresh",detail:"continue with a fresh conversation \u2014 earlier answers may be re-asked"},{label:"stop",detail:"stop here; the session stays resumable"}],recommended_index:1,allow_free_text:!1}]);if((Array.isArray(t)?t.find(p=>p.id==="binding-mismatch"):void 0)?.selected_index!==0){let p=`resume abandoned: binding mismatch on session ${De} \u2014 the session is preserved`;return e.out(p),e.emit?.({type:"error",message:p,code:"BINDING_MISMATCH"}),2}g("binding_migrate",{sid:De},C.session_id),ze?.();let m=C.resume&&"schema"in C.resume?{...C.resume,binding:{}}:void 0;try{w=await ut({...C,...m?{resume:m}:{}},{...j,graphSlot:b,...te?{checkpoint:te}:{}},Ge,d,g,J?St:void 0,()=>de.current)}catch(p){if(p instanceof Ae)return re?.(),e.chat?.setWorking?.(null),e.out(`error: ${p.message}`),e.emit?.({type:"error",code:"PAIR_MISMATCH",message:p.message}),2;throw re?.(),p}re?.(),e.chat?.setWorking?.(null)}if(w.error){let t=w.error.startsWith("proposal failed validation after repair:");t&&g("agent_error_detail",{error:w.error},C.session_id);let o=t?`error: the agent could not produce a valid proposal for ${s.source_id} \u2014 re-run kane-cli context extract to retry`:`error: agent failed for ${s.source_id}: ${w.error}`;e.out(o),e.emit?.({type:"error",source_id:s.source_id,message:o}),U.push(s.source_id);continue}if(w.highRisk)return e.out(`error: ${w.highRisk.length} high-risk decision${w.highRisk.length===1?"":"s"} need a human \u2014 ci mode won't guess. Re-run with --mode agent to pause for review.`),e.emit?.({type:"error",source_id:s.source_id,message:`error: high-risk question(s) in ci mode (fail-closed): ${w.highRisk.map(t=>t.id).join(", ")}`,code:"HIGH_RISK_CI"}),1;if(w.paused){let t=I.slice(u+1).map(E=>E.source_id),o=n?.handle??P,m=o??it(e.contextDir,{sid:C.session_id,mode:"agent",created_at:(e.now?.()??new Date).toISOString(),expires_at:new Date((e.now?.()??new Date).getTime()+1440*60*1e3).toISOString(),agent_state:w.paused.agent_state,pending:{questions:[],proposals:[]},assumed:[],read_basis:{[s.source_id]:s.cid},corpus_cursor:{remaining:t},conv_source:Q,verb:"extract",...oe?{force:!0}:{},...r.changeContext?{change_basis:{source_id:r.changeContext.source_id,new_head:r.changeContext.new_head}}:{},...l?{user_session_id:l.ids.session_id}:{}});ve=!0;try{Q&&m.state.conv_source!==Q&&m.save({conv_source:Q});let E=e.chat?.drainHeldReceipts?.()??[];(E.length>0||(m.state.held_receipts?.length??0)>0)&&m.save({held_receipts:E}),o&&m.save({read_basis:{[s.source_id]:s.cid},corpus_cursor:{remaining:t},...oe&&!m.state.force?{force:!0}:{},...l&&m.state.user_session_id!==l.ids.session_id?{user_session_id:l.ids.session_id}:{}}),er(m,w.paused)}catch(E){let S=m.state.checkpoint,R=`error: couldn't persist the pause for session ${m.state.sid}`+(S?` \u2014 last durable checkpoint: seq ${S.seq} @ ${S.ts}`:" \u2014 no durable checkpoint exists")+` (${E instanceof Error?E.message:String(E)})`;return e.out(R),e.emit?.({type:"error",message:R,code:"PAUSE_PERSIST_FAILED",sid:m.state.sid}),1}g("session_paused",{sid:m.state.sid},C.session_id);let p=`kane-cli context extract --resume ${m.state.sid} --mode ${c}`;return e.out(`paused: session ${m.state.sid} saved \u2014 resume with: ${p}`),e.emit?.({type:"session_paused",sid:m.state.sid,source_id:s.source_id,mode:c,resume:p,expires_at:m.state.expires_at,pending_questions:w.paused.pending.questions}),e.chat?.ledger?.({kind:"pause",sid:m.state.sid,expires_at:m.state.expires_at,resume:p,messageForm:`${p} --message "<your words>"`}),3}if(w.crashed){let t=y?.state.checkpoint;if(y&&t){let o=`kane-cli context extract --resume ${y.state.sid} --mode ${c}`;try{y.save({read_basis:{[s.source_id]:s.cid},corpus_cursor:{remaining:qe}})}catch{}return g("agent_crashed_resumable",{sid:y.state.sid,seq:t.seq},C.session_id),e.out(`agent crashed \u2014 session ${y.state.sid} is resumable at checkpoint seq ${t.seq} (at most the in-flight turn lost); resume with: ${o}`),e.emit?.({type:"session_paused",sid:y.state.sid,source_id:s.source_id,mode:c,resume:o,expires_at:y.state.expires_at,crashed:!0}),e.chat?.ledger?.({kind:"pause",sid:y.state.sid,expires_at:y.state.expires_at,resume:o,messageForm:`${o} --message "<your words>"`}),ve=!0,y.release(),3}e.out(`error: agent crashed for ${s.source_id} with no durable checkpoint`),e.emit?.({type:"error",source_id:s.source_id,message:`error: agent crashed for ${s.source_id} with no durable checkpoint`,code:"AGENT_CRASHED"}),U.push(s.source_id);continue}if(J){if(pt+=w.assumedDefaults??0,w.error||kt)return 1;if(!bt&&!We){let t=I.length-u-1;e.out(`done \u2014 nothing committed for ${s.source_id} (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)`:""));{let o=(y?.state.ingest_schedule??[]).filter(m=>m.status==="pending");o.length>0&&e.out(`note: ${o.length} source(s) landed this session (${o.map(m=>m.source_id).join(", ")}) were not extracted \u2014 the session ended first; kane-cli context extract runs them`)}return n&&s.source_id in n.handle.state.read_basis&&(n.handle.complete(),n=null,y=null),ft(),0}n&&s.source_id in n.handle.state.read_basis&&!We&&(a(u),n.handle.complete(),n=null,y=null);continue}if(!w.proposal){e.out(`error: agent ended without a proposal for ${s.source_id}`),e.emit?.({type:"error",source_id:s.source_id,message:`error: agent ended without a proposal for ${s.source_id}`}),U.push(s.source_id);continue}let q=ge(w.proposal,Re(d,w.proposal),d);if(g("kane_validate",{errors:q.map(t=>t.code)},C.session_id),q.length>0&&Cr(w.proposal,q,t=>e.out(t))&&(g("criteria_dropped",{source_id:s.source_id},C.session_id),q=ge(w.proposal,Re(d,w.proposal),d)),q.length>0){e.out("the agent's proposal didn't validate \u2014 retrying once"),e.emit?.({type:"validate_failed",source_id:s.source_id,codes:q.map(t=>t.code),repairing:!0}),g("repair_respawn",{source_id:s.source_id},C.session_id),D&&ce||(wt=y?.state.checkpoint?.seq??0);try{w=await ut(C,{...j,graphSlot:b,...te?{checkpoint:te}:{}},Ge,d,g,void 0,()=>de.current)}catch(t){if(t instanceof Ae)return e.out(`error: ${t.message}`),e.emit?.({type:"error",code:"PAIR_MISMATCH",message:t.message}),2;throw t}if(w.error||!w.proposal){e.out(`error: repair run failed for ${s.source_id}`),e.emit?.({type:"error",source_id:s.source_id,message:`error: repair run failed for ${s.source_id}`}),U.push(s.source_id);continue}if(q=ge(w.proposal,Re(d,w.proposal),d),q.length>0){e.out("details (agent-facing):");for(let t of q)e.out(` ${t.detail}`);e.emit?.({type:"validate_failed",source_id:s.source_id,codes:q.map(t=>t.code),repairing:!1}),e.emit?.({type:"error",source_id:s.source_id,message:`error: proposal failed validation after repair (${q.map(t=>t.code).join(", ")})`}),U.push(s.source_id);continue}}let T=w.proposal,Ee=gr(T,d),Ke=ee(e.contextDir,"proposals",ae);if(ct(Ke,{recursive:!0}),dt(ee(Ke,"proposal.json"),JSON.stringify(T,null,2)+`
11
- `),r.plan){e.out(`plan: ${T.use_cases.length} use-case(s) proposed from ${s.source_id} (nothing committed)`);for(let t of T.use_cases){let o=Ee.get(t.temp_ref),m=o?o.archived?` \u2248 matches ARCHIVED ${o.cid.slice(0,19)}${o.reason?` \u2014 previously rejected: "${o.reason}"`:" \u2014 previously rejected"}`:` \u2248 matches ${o.cid.slice(0,19)}`:"";e.out(` [${t.risk}] ${t.title} \u2014 cite ${t.cite.anchor}${m}`)}e.emit?.({type:"plan",source_id:s.source_id,use_cases:T.use_cases.map(t=>{let o=Ee.get(t.temp_ref);return{risk:t.risk,title:t.title,anchor:t.cite.anchor,...o?{match:o.cid,match_archived:!!o.archived}:{}}})}),w.assumedDefaults&&e.out(`assumed: ${w.assumedDefaults} default(s) auto-taken (assumed)`);continue}for(let t of T.use_cases){if(!t.conflicts_with?.length)continue;let o=t.conflicts_with.filter(p=>d.resolve(p)!==null),m=t.conflicts_with.filter(p=>d.resolve(p)===null);m.length>0&&(e.out(`note: ${t.temp_ref}: dropped unresolvable conflict hint(s): ${m.join(", ")}`),t.conflicts_with=o.length>0?o:void 0)}g("review_start",{use_cases:T.use_cases.length,flags:Ee.size},C.session_id);let Pe=await e.review(T.use_cases,Ee);if(g("review_verdicts",[...Pe.entries()].map(([t,o])=>({ref:t,resolution:o.resolution})),C.session_id),dt(ee(Ke,"review.json"),JSON.stringify(T.use_cases.map(t=>{let o=Pe.get(t.temp_ref)??{resolution:"skipped"};return{id:t.temp_ref,kind:"review-item",resolution:o.resolution,edit:o.edit??null,reason:o.reason??null,...o.supersedeTarget?{supersede_target:o.supersedeTarget}:{},by:be}}),null,2)+`
12
- `),(ke||r.trust==="hold")&&$e()&&T.use_cases.some(t=>t.matches_existing==null)){Be(s,T.use_cases,ke?"degraded":"trust_hold");continue}let $t=ur(e.contextDir,C.session_id,mt,e.probe,e.auth),Ct=t=>{if(t.degradedProbe&&$e()!==null&&T.use_cases.some(m=>m.matches_existing==null))return{result:{degradedHold:!0},record:null};let o=st({contextDir:e.contextDir,graph:t.graph,proposal:T,proposalId:ae,verdicts:Pe,by:be,autoName:!0,allowStaleBasis:!0,eventIds:t.eventIds("extract",1),...Y?{sid:t.sid}:{},probeHits:t.probeHits});return o.errors!==null?{errors:o.errors}:{result:o,record:o.record}},Rt=lr(T,d),H=await Oe($t,Rt,Ct);if(!H.ok&&H.kind==="drifted"){if(!await e.confirmStale(`the context changed while you reviewed (${H.asks.map(o=>o.detail).join("; ")}) \u2014 commit against the new head anyway?`)){e.out("aborted: proposal not committed"),e.emit?.({type:"error",source_id:s.source_id,message:"aborted: proposal not committed",code:"STALE_BASIS"}),U.push(s.source_id);continue}H=await Oe($t,{...Rt,sourcePins:[]},Ct)}let Je=H.ok&&"result"in H?H.result:null;if(Je!==null&&"degradedHold"in Je){Ue(),Be(s,T.use_cases,"degraded");continue}let Te=Je??(H.ok?{record:null,errors:null}:{record:null,errors:H.kind==="validation"?H.errors:H.kind==="contended"?[{code:H.err.code,detail:`a use-case this proposal touches is held by ${H.err.holder?.owner_sid??"another session"} \u2014 try again when it frees`}]:[{code:"UNSETTLED",detail:"concurrent activity kept moving the store \u2014 retry when quieter"}]});if(Te.errors){for(let t of Te.errors)e.out(` ${t.detail}`);e.emit?.({type:"error",source_id:s.source_id,message:`error: commit failed: ${Te.errors.map(t=>`${t.code}: ${t.detail}`).join("; ")}`}),U.push(s.source_id);continue}let _r=new Date().toISOString();for(let t of T.use_cases){let o=Pe.get(t.temp_ref)??{resolution:"skipped"};for(let m of Vt({ts:_r,command:"context extract",id:t.temp_ref,by:be},o.resolution))Wt(e.contextDir,m)}let V=Te.record;V.event_ids?.length&&y?.markApplied(V.event_ids);let Xe=new Map(V.review.map(t=>[t.id,t.resolution])),Ye=[...Xe.values()].filter(t=>t==="approved"||t==="edited").length,Qe=[...Xe.values()].filter(t=>t==="rejected").length,Ze=V.nodes.filter(t=>!Xe.has(t.cid)).length,et=V.supersessions.filter(t=>t.kind==="node"&&t.new!==t.old).length;g("commit",{trusted:Ye,derived:Ze,archived:Qe},C.session_id),e.out(`committed: ${Ye} trusted, ${Ze} derived (awaiting review), ${Qe} archived`+(et>0?`, ${et} superseded`:""));{let t=V.review.filter(o=>o.kind==="pending_update");t.length>0&&(e.out(`${t.length} update(s) held for review`),e.emit?.({type:"update_held",count:t.length,targets:t.map(o=>o.id)}))}w.assumedDefaults&&e.out(`assumed: ${w.assumedDefaults} default(s) auto-taken (assumed)`),e.emit?.({type:"commit",source_id:s.source_id,proposal_id:ae,trusted:Ye,derived:Ze,archived:Qe,superseded:et,assumed:w.assumedDefaults??0,evidence_matched:Math.max(0,T.use_cases.length-V.nodes.length),minted:V.nodes.map(t=>{let o=V.names?.find(m=>m.cid===t.cid)?.slug;return{cid:t.cid,...o?{logical_id:o}:{}}})}),n&&s.source_id in n.handle.state.read_basis&&(a(u),n.handle.complete(),e.out(`session ${r.resume} complete`),e.emit?.({type:"session_complete",sid:r.resume,source_id:s.source_id}),l?.event("ASR_SESSION_COMPLETE",{}),n=null,y=null)}if(y){let u=y.state.ingest_schedule??[];u.some(s=>s.status==="pending")&&y.save({ingest_schedule:u.map(s=>s.status==="pending"?{...s,status:"skipped",note:"run ended before its turn \u2014 kane-cli context extract runs it"}:s)})}_t=!0}finally{if(n?.handle.release(),P&&!ve&&!_t){let a=P.state.checkpoint;if(a){let u=`kane-cli context extract --resume ${P.state.sid} --mode ${c}`;e.out(`session ${P.state.sid} kept its last checkpoint (seq ${a.seq}, ${a.ts}) \u2014 resume with: ${u}`),P.release()}else{try{P.complete()}catch{P.release()}ht()}P=null}}if(J){let a=e.chat?.state.ledger.filter(d=>d.kind==="answer"&&d.receipt.form==="assumed").length??0,u=pt+a,s=e.chat?.state.credits?.total;e.chat?.ledger?.({kind:"summary",lines:[`saved ${He} use-case${He===1?"":"s"} across ${I.length} source${I.length===1?"":"s"}`,...u>0?[`${u} assumed default(s)`]:[],...s!==void 0?[`credits used: ${s.toFixed(1)}`]:[],`trace: ${ot(_)}`]})}if(r.plan||sr(e.contextDir),Se>0&&(P||je)){ve=!0;let a=P?.state.sid??je,u=`kane-cli context extract --resume ${a} --mode ${c}`;return e.out(`paused: ${Se} held item(s) await review \u2014 resume with: ${u}`),e.emit?.({type:"session_paused",sid:a,resume:u,held:Se}),P?.release(),3}return U.length>0&&e.out(`${U.length} of ${I.length} source(s) failed \u2014 re-run kane-cli context extract to retry (${U.join(", ")})`),ft(),U.length>0?1:0}export{ur as a,kr as b,mr as c,fr as d,$r as e,gr as f,ws as g};
@@ -1,2 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as f}from"./chunk-R2RGSO4B.js";import{y as t}from"./chunk-C4G7RVJ6.js";import{a as x}from"./chunk-HCBYKLMW.js";import{a as r,b as n}from"./chunk-C44QQJR4.js";import{a as B}from"./chunk-6YGTRKDT.js";import{e as p}from"./chunk-UR6MHSHU.js";var c=p(B(),1);var e=p(x(),1);function v(){return[{name:"convert",label:"Converting session data",status:"pending"},{name:"zip",label:"Compressing artifacts",status:"pending"},{name:"presign",label:"Requesting upload URLs",status:"pending"},{name:"upload",label:"Uploading to KaneAI",status:"pending"},{name:"atomic_replace",label:"Replacing local output",status:"pending"},{name:"commit_lock",label:"Committing to TMS",status:"pending"},{name:"finalize",label:"Finalizing test case",status:"pending"},{name:"code_export",label:"Downloading test code",status:"pending"}]}function U(s,o,d,a){return s.map(l=>l.name===o?{...l,status:d,detail:a}:l)}function R(s){let o=s/1e3;if(o<60)return`${o.toFixed(1)}s`;let d=Math.floor(o/60),a=Math.round(o%60);return`${d}m ${a}s`}function D(s){let[o,d]=(0,c.useState)(0),a=c.default.useRef(Date.now());return(0,c.useEffect)(()=>{if(!s)return;a.current=Date.now();let l=setInterval(()=>{d(Date.now()-a.current)},100);return()=>clearInterval(l)},[s]),o}function h({steps:s,status:o,testUrl:d,error:a}){let l=D(o==="uploading");return o==="uploading"?(0,e.jsxs)(r,{flexDirection:"column",paddingX:1,paddingY:1,children:[(0,e.jsxs)(r,{children:[(0,e.jsx)(n,{color:t.orange,children:"\u2601 "}),(0,e.jsx)(n,{color:t.orange,bold:!0,children:"Saving to KaneAI"}),(0,e.jsxs)(n,{color:t.dim,children:[" ",R(l)]})]}),(0,e.jsx)(r,{flexDirection:"column",marginTop:1,children:s.filter(i=>i.status!=="skipped").map((i,S,T)=>{let b=S===T.length-1?"\u2514\u2500":"\u251C\u2500",u=i.status==="done",m=i.status==="running",g=i.status==="failed";return(0,e.jsxs)(r,{children:[(0,e.jsxs)(n,{color:t.dim,children:[" ",b," "]}),(0,e.jsx)(r,{width:3,children:m?(0,e.jsx)(f,{}):u?(0,e.jsx)(n,{color:t.green,children:"\u2713"}):g?(0,e.jsx)(n,{color:t.red,children:"\u2717"}):(0,e.jsx)(n,{color:t.muted,children:"\u25CB"})}),(0,e.jsx)(n,{color:u?t.dim:m?void 0:g?t.red:t.muted,children:i.label}),i.detail&&(0,e.jsxs)(n,{color:t.dim,children:[" ",i.detail]})]},i.name)})}),(0,e.jsx)(r,{marginTop:1,children:(0,e.jsx)(n,{color:t.muted,children:" press Ctrl+C twice to force exit"})})]}):o==="success"?(0,e.jsx)(e.Fragment,{}):(0,e.jsxs)(r,{flexDirection:"column",paddingX:1,paddingY:1,children:[(0,e.jsxs)(r,{children:[(0,e.jsx)(n,{color:t.red,children:"\u2601 "}),(0,e.jsx)(n,{color:t.red,bold:!0,children:"Save failed"})]}),a&&(0,e.jsxs)(r,{marginTop:0,children:[(0,e.jsx)(n,{color:t.dim,children:" "}),(0,e.jsx)(n,{color:t.dim,children:a})]})]})}export{v as a,U as b,h as c};